-
Notifications
You must be signed in to change notification settings - Fork 36.7k
add go to command for terminal accessible buffer
#177110
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 2 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
93e4260
wip
meganrogge 35d72f1
rename, play audio cue on active item change if exit code is non-zero
meganrogge 691ac5d
Update src/vs/workbench/contrib/terminalContrib/accessibility/browser…
meganrogge 1fa0e0c
add context key, get keybindings to work
meganrogge bfe9a62
fix some issues
meganrogge 13bc73c
rename
meganrogge 6d7934e
move closer to usage
meganrogge 5655bbe
return quickpick
meganrogge cb11ee7
rm inQuickPick
meganrogge 0270a93
Update src/vs/workbench/contrib/terminalContrib/accessibility/browser…
meganrogge File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -21,6 +21,9 @@ import { getSimpleEditorOptions } from 'vs/workbench/contrib/codeEditor/browser/ | |
| import { ITerminalFont } from 'vs/workbench/contrib/terminal/common/terminal'; | ||
| import { IXtermTerminal } from 'vs/workbench/contrib/terminal/browser/terminal'; | ||
| import type { Terminal } from 'xterm'; | ||
| import { ITerminalCapabilityStore, TerminalCapability } from 'vs/platform/terminal/common/capabilities/capabilities'; | ||
| import { IQuickInputService, IQuickPickItem } from 'vs/platform/quickinput/common/quickInput'; | ||
| import { AudioCue, IAudioCueService } from 'vs/platform/audioCues/browser/audioCueService'; | ||
|
|
||
| const enum Constants { | ||
| Scheme = 'terminal-accessible-buffer', | ||
|
|
@@ -34,14 +37,18 @@ export class AccessibleBufferWidget extends DisposableStore { | |
| private _bufferEditor: CodeEditorWidget; | ||
| private _editorContainer: HTMLElement; | ||
| private _font: ITerminalFont; | ||
| private _inQuickPick = false; | ||
| private _xtermElement: HTMLElement; | ||
|
|
||
| constructor( | ||
| private readonly _instanceId: number, | ||
| private readonly _xterm: IXtermTerminal & { raw: Terminal }, | ||
| private readonly _capabilities: ITerminalCapabilityStore, | ||
| @IInstantiationService private readonly _instantiationService: IInstantiationService, | ||
| @IModelService private readonly _modelService: IModelService, | ||
| @IConfigurationService private readonly _configurationService: IConfigurationService | ||
| @IConfigurationService private readonly _configurationService: IConfigurationService, | ||
| @IQuickInputService private readonly _quickInputService: IQuickInputService, | ||
| @IAudioCueService private readonly _audioCueService: IAudioCueService | ||
| ) { | ||
| super(); | ||
| const codeEditorWidgetOptions: ICodeEditorWidgetOptions = { | ||
|
|
@@ -101,6 +108,9 @@ export class AccessibleBufferWidget extends DisposableStore { | |
| })); | ||
| this._updateEditor(); | ||
| this.add(this._bufferEditor.onDidFocusEditorText(async () => { | ||
| if (this._inQuickPick) { | ||
| return; | ||
| } | ||
|
||
| // if the editor is focused via tab, we need to update the model | ||
| // and show it | ||
| await this._updateEditor(); | ||
|
|
@@ -145,6 +155,48 @@ export class AccessibleBufferWidget extends DisposableStore { | |
| this._bufferEditor.setScrollTop(this._bufferEditor.getScrollHeight()); | ||
| } | ||
|
|
||
| showCommandQuickPick(): void { | ||
| const commands = this._capabilities.get(TerminalCapability.CommandDetection)?.commands; | ||
| const quickPick = this._quickInputService.createQuickPick<IQuickPickItem>(); | ||
| const quickPickItems: IQuickPickItem[] = []; | ||
meganrogge marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| if (!commands?.length) { | ||
| return; | ||
| } | ||
| for (const command of commands) { | ||
| const line = command.marker?.line; | ||
| if (!line) { | ||
| continue; | ||
| } | ||
| quickPickItems.push( | ||
| { | ||
| label: localize('terminal.integrated.symbolQuickPick.labelNoExitCode', '{0}', command.command), | ||
| meta: JSON.stringify({ line: line + 1, exitCode: command.exitCode }) | ||
| }); | ||
| } | ||
| quickPick.onDidAccept(() => { | ||
| this._inQuickPick = true; | ||
| const item = quickPick.activeItems[0]; | ||
| const model = this._bufferEditor.getModel(); | ||
| if (!model || !item.meta) { | ||
| return; | ||
| } | ||
| quickPick.hide(); | ||
| const data: { line: number; exitCode: number } = JSON.parse(item.meta); | ||
| this._bufferEditor.setSelection({ startLineNumber: data.line, startColumn: 1, endLineNumber: data.line, endColumn: 1 }); | ||
| this._bufferEditor.revealLine(data.line); | ||
| this._bufferEditor.focus(); | ||
| this._inQuickPick = false; | ||
| return; | ||
| }); | ||
| quickPick.onDidChangeActive(() => { | ||
| if (JSON.parse(quickPick.activeItems[0].meta!).exitCode) { | ||
| this._audioCueService.playAudioCue(AudioCue.error, true); | ||
| } | ||
| }); | ||
| quickPick.items = quickPickItems; | ||
| quickPick.show(); | ||
meganrogge marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| } | ||
|
|
||
| async show(): Promise<void> { | ||
| await this._updateEditor(); | ||
| this._accessibleBuffer.tabIndex = -1; | ||
|
|
@@ -159,7 +211,6 @@ export class AccessibleBufferWidget extends DisposableStore { | |
| if (existing && !existing.isDisposed()) { | ||
| return existing; | ||
| } | ||
meganrogge marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| return this._modelService.createModel(resource.fragment, null, resource, false); | ||
| } | ||
|
|
||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.