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/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/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()) { @@ -445,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", @@ -468,31 +467,33 @@ 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; function finish(value?: string): void { @@ -507,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; @@ -558,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()); @@ -632,7 +643,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 +728,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 +743,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