From bb433b24bb14036af179a109f816390d42561ef7 Mon Sep 17 00:00:00 2001 From: Andreas Ragnerstam Date: Fri, 4 Dec 2026 10:46:53 +0100 Subject: [PATCH 1/2] Keep multi-step prompts open when focus leaves Adding or editing a symbol file asks for the file, the contexts and the load address, one prompt after the other. VS Code closed the prompt when the user clicked in another window, for example to copy a relocation address, and the user had to start over. The prompts of the symbol file flow, the context picker and the symbol prompt of function breakpoints now stay open until the user accepts or presses Escape. The context picker is shared, so path map rules and the launch configurations editor get the same behavior. The prompts also stay open when the user clicks elsewhere in VS Code. Signed-off-by: Andreas Ragnerstam --- CHANGELOG.md | 4 ++++ src/contextPicker.ts | 3 +++ src/extension.ts | 6 +++++- 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8366679..aba75b1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -74,6 +74,10 @@ All notable changes to the Simics Target Debug extension will be documented here - The Start button in TCF Launch Configurations is no longer disabled while any Simics Target Debug session runs, only for configurations that connect to an agent (host and port) that already has a session. +- The prompts for adding and editing symbol files, the context picker and + the symbol prompt of function breakpoints stay open when VS Code loses + focus, so you can copy an address or context from another window. Press + Escape to cancel them. ## [0.5.0] - 2026-11-02 diff --git a/src/contextPicker.ts b/src/contextPicker.ts index 4c0bf71..0ff8fcb 100644 --- a/src/contextPicker.ts +++ b/src/contextPicker.ts @@ -76,6 +76,7 @@ function chooseScope(options: PickContextsOptions): Promise(); picker.title = options.title; picker.placeholder = "Choose the contexts it applies to"; + picker.ignoreFocusOut = true; picker.matchOnDescription = true; const menu = scopeMenuItems(options.scope, options.contexts, options.selectedId); const items: MenuItem[] = menu.map(({ label, description, action }) => ({ label, description, action })); @@ -115,6 +116,7 @@ function check(options: PickContextsOptions, initial: readonly string[]): Promis picker.title = options.title; picker.placeholder = options.placeholder ?? "Check one or more contexts"; picker.canSelectMany = true; + picker.ignoreFocusOut = true; picker.matchOnDescription = true; picker.matchOnDetail = true; picker.buttons = [vscode.QuickInputButtons.Back]; @@ -187,6 +189,7 @@ function enterQuery(options: PickContextsOptions, initial: string): Promise (!value.trim() ? "Enter a symbol or expression" : undefined), }); if (!symbol?.trim()) { @@ -493,6 +494,7 @@ function promptSymbolFilePath(workspaceFolder?: string, initialPath = ""): Promi const picker = vscode.window.createQuickPick(); picker.title = initialPath ? "Update Symbol File Path" : "Add Symbol File"; picker.placeholder = "Type an agent path or select a suggested local file or folder"; + picker.ignoreFocusOut = true; let finished = false; function finish(value?: string): void { @@ -632,7 +634,7 @@ async function editSymbolFile(item?: SymbolFileViewItem): Promise { { label: "Contexts", description: capitalize(describeContextScope(file)), field: "contexts" }, { label: "Load Address", description: describeLoadAddress(file), field: "address" }, ], - { title: "Edit Symbol Mapping", placeHolder: "Select a field to update" }, + { title: "Edit Symbol Mapping", placeHolder: "Select a field to update", ignoreFocusOut: true }, ); if (!selected) { return; @@ -717,6 +719,7 @@ async function promptLoadAddress( const mode = await vscode.window.showQuickPick(items, { title: "Load Address", placeHolder: "How are the symbols placed in memory?", + ignoreFocusOut: true, }); if (!mode) { return undefined; @@ -731,6 +734,7 @@ async function promptLoadAddress( ? "Address of the first loadable segment, hex or decimal (for example 0x100000)" : "Offset added to the file addresses, hex or decimal, may be negative (for example 0x1000 or -0x1000)", value: currentMode === mode.mode ? formatConfigAddress(current?.address) : "", + ignoreFocusOut: true, validateInput: (v) => (absolute ? /^(0x[0-9a-f]+|\d+)$/i : /^-?\s*(0x[0-9a-f]+|\d+)$/i).test(v.trim()) ? undefined From 66cb3f578f6b09798088220277b6d1f562cf560c Mon Sep 17 00:00:00 2001 From: Andreas Ragnerstam Date: Fri, 4 Dec 2026 10:51:02 +0100 Subject: [PATCH 2/2] Do not accept a folder as a symbol file The symbol file picker offered Browse for a Folder, and Use this path took a local folder too. The folder was then sent to the agent as a memory map region, which it cannot load, so no symbols were added and nothing told the user why. Only files can be picked now. A typed local folder is listed instead of used, like a selected folder suggestion. A path that does not exist on this host is still accepted, since it may be a file that only the agent can read. Signed-off-by: Andreas Ragnerstam --- docs/configuration/symbol-files.md | 5 +- src/extension.ts | 77 +++++++++++++++++------------- 2 files changed, 45 insertions(+), 37 deletions(-) diff --git a/docs/configuration/symbol-files.md b/docs/configuration/symbol-files.md index d5691f7..fa08423 100644 --- a/docs/configuration/symbol-files.md +++ b/docs/configuration/symbol-files.md @@ -65,9 +65,8 @@ from the Command Palette. Enter: - The path as seen by the agent. Relative paths are resolved against the debug session's workspace folder. As you type the path, local files and folders are suggested; select a folder to list it, or `..` for its parent - folder. **Browse for a File...** and **Browse for a Folder...** open the - file dialog. Enter a path directly if the file is only available to the - agent. + folder. **Browse for a File...** opens the file dialog. Enter a path + directly if the file is only available to the agent. - The contexts the symbols apply to, with the [context picker](/configuration/contexts#the-context-picker). - How the symbols are placed: the file addresses, a relocation offset (like diff --git a/src/extension.ts b/src/extension.ts index 38a3cbe..77cb758 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -446,22 +446,20 @@ async function addSymbolFile(symbolFiles: SymbolFilesProvider): Promise { interface SymbolPathChoice extends vscode.QuickPickItem { path: string; directory?: boolean; - browse?: "file" | "folder"; + browse?: true; } -const BROWSE_CHOICES: SymbolPathChoice[] = [ - { label: "$(file) Browse for a File...", path: "", browse: "file", alwaysShow: true }, - { label: "$(folder-opened) Browse for a Folder...", path: "", browse: "folder", alwaysShow: true }, -]; +const BROWSE_CHOICE: SymbolPathChoice = { + label: "$(file) Browse for a File...", + path: "", + browse: true, + alwaysShow: true, +}; -async function browseSymbolPath( - pick: "file" | "folder", - typed: string, - workspaceFolder?: string, -): Promise { +async function browseSymbolFile(typed: string, workspaceFolder?: string): Promise { const uris = await vscode.window.showOpenDialog({ - canSelectFiles: pick === "file", - canSelectFolders: pick === "folder", + canSelectFiles: true, + canSelectFolders: false, canSelectMany: false, defaultUri: startFolder(typed, workspaceFolder), openLabel: "Select", @@ -469,31 +467,32 @@ async function browseSymbolPath( return uris?.[0]?.fsPath; } -// A file as defaultUri makes VS Code's simple file dialog behave like a save dialog. -function startFolder(typed: string, workspaceFolder?: string): vscode.Uri | undefined { +/** The typed path on this host, resolved against the workspace folder. */ +function localSymbolPath(typed: string, workspaceFolder?: string): string | undefined { const value = typed.trim(); - const resolved = !value - ? undefined - : path.isAbsolute(value) - ? value - : workspaceFolder && path.join(workspaceFolder, value); - for (const candidate of resolved ? [resolved, path.dirname(resolved)] : []) { - try { - if (fs.statSync(candidate).isDirectory()) { - return vscode.Uri.file(candidate); - } - } catch { - // Try the next candidate. - } + return !value ? undefined : path.isAbsolute(value) ? value : workspaceFolder && path.join(workspaceFolder, value); +} + +function isLocalFolder(file: string | undefined): boolean { + try { + return file !== undefined && fs.statSync(file).isDirectory(); + } catch { + return false; } - return workspaceFolder ? vscode.Uri.file(workspaceFolder) : undefined; +} + +// A file as defaultUri makes VS Code's simple file dialog behave like a save dialog. +function startFolder(typed: string, workspaceFolder?: string): vscode.Uri | undefined { + const resolved = localSymbolPath(typed, workspaceFolder); + const folder = (resolved ? [resolved, path.dirname(resolved)] : []).find(isLocalFolder); + return folder ? vscode.Uri.file(folder) : workspaceFolder ? vscode.Uri.file(workspaceFolder) : undefined; } function promptSymbolFilePath(workspaceFolder?: string, initialPath = ""): Promise { return new Promise((resolve) => { const picker = vscode.window.createQuickPick(); picker.title = initialPath ? "Update Symbol File Path" : "Add Symbol File"; - picker.placeholder = "Type an agent path or select a suggested local file or folder"; + picker.placeholder = "Type an agent path or select a suggested local file"; picker.ignoreFocusOut = true; let finished = false; @@ -509,9 +508,11 @@ function promptSymbolFilePath(workspaceFolder?: string, initialPath = ""): Promi async function update(value: string): Promise { const typed = value.trim(); + // A local folder is not a symbol file; the suggestions list it instead. + const usable = typed && !isLocalFolder(localSymbolPath(typed, workspaceFolder)); const manual: SymbolPathChoice[] = [ - ...(typed ? [{ label: typed, description: "Use this path", path: typed }] : []), - ...BROWSE_CHOICES, + ...(usable ? [{ label: typed, description: "Use this path", path: typed }] : []), + BROWSE_CHOICE, ]; picker.items = manual; picker.busy = true; @@ -560,11 +561,19 @@ function promptSymbolFilePath(workspaceFolder?: string, initialPath = ""): Promi const typed = picker.value; finished = true; picker.dispose(); - resolve(browseSymbolPath(selected.browse, typed, workspaceFolder)); + resolve(browseSymbolFile(typed, workspaceFolder)); } else if (selected?.directory) { picker.value = selected.path + path.sep; - } else if (selected?.path || picker.value.trim()) { - finish(selected?.path ?? picker.value.trim()); + } else { + const chosen = selected?.path ?? picker.value.trim(); + if (!chosen) { + return; + } + if (!isLocalFolder(localSymbolPath(chosen, workspaceFolder))) { + finish(chosen); + } else if (!chosen.endsWith(path.sep)) { + picker.value = chosen + path.sep; + } } }); picker.onDidHide(() => finish());