fix(http-client): let the selected environment override file variables (#5532)

The ide-http resolver looked up @name file variables before the environment, so selecting an environment had no effect on a name the .http file also defines. As in the JetBrains HTTP Client (environment variables rank above in-place variables), the order with an environment selected is now private env, public env, $shared, then file variables; without one, file variables still come before $shared. Go to Declaration on {{name}} lists targets in the same order; the guide (en, zh) documents it. Fixes #5530.

Co-authored-by: wildcatDownstairs <[email protected]>
Цей коміт міститься в:
LU XIANGRUIтаwildcatDownstairs authored and GitHub committed 2026-11-24 21:10:31 +08:00
1 джерело 4a14efc168
коміт bee5e2ed1f
5 files changed
+49 -25

No files matched your search

+4 -4
Переглянути файл
@@ -1,7 +1,7 @@
/**
* Navigate › Declaration (⌘-click, ⌘B) on `{{name}}` in a `.http` file: the `@name = …` line of
* the same file, then the key `name` in each environment of the nearest
* `http-client.private.env.json` and `http-client.env.json` — the variable lookup order.
* Navigate › Declaration (⌘-click, ⌘B) on `{{name}}` in a `.http` file: the key `name` in each
* environment of the nearest `http-client.private.env.json` and `http-client.env.json`, then the
* `@name = …` line of the same file — the variable lookup order with an environment selected.
*/
import type { Text } from "@codemirror/state";
import { registerNavigationProvider } from "@/editor/api";
@@ -49,6 +49,6 @@ export function registerVariableNavigation(): () => void {
} catch {
// No project or unreadable environment files: the file's own definitions still count.
}
return { from: at.from, to: at.to, targets: [...inFile, ...inEnv] };
return { from: at.from, to: at.to, targets: [...inEnv, ...inFile] };
});
}