provide screen reader with inline suggestions (#175823)

This commit is contained in:
Megan Rogge
2023-03-07 13:14:11 -06:00
committed by GitHub
parent ed04b28c4d
commit dcebcb60df
5 changed files with 304 additions and 309 deletions

View File

@@ -57,6 +57,10 @@ export interface IEditorOptions {
* The aria label for the editor's textarea (when it is focused). * The aria label for the editor's textarea (when it is focused).
*/ */
ariaLabel?: string; ariaLabel?: string;
/**
* Control whether a screen reader announces inline suggestion content immediately.
*/
screenReaderAnnounceInlineSuggestion?: boolean;
/** /**
* The `tabindex` property of the editor's textarea * The `tabindex` property of the editor's textarea
*/ */
@@ -4754,6 +4758,7 @@ export const enum EditorOption {
accessibilityPageSize, accessibilityPageSize,
ariaLabel, ariaLabel,
autoClosingBrackets, autoClosingBrackets,
screenReaderAnnounceInlineSuggestion,
autoClosingDelete, autoClosingDelete,
autoClosingOvertype, autoClosingOvertype,
autoClosingQuotes, autoClosingQuotes,
@@ -4918,6 +4923,13 @@ export const EditorOptions = {
ariaLabel: register(new EditorStringOption( ariaLabel: register(new EditorStringOption(
EditorOption.ariaLabel, 'ariaLabel', nls.localize('editorViewAccessibleLabel', "Editor content") EditorOption.ariaLabel, 'ariaLabel', nls.localize('editorViewAccessibleLabel', "Editor content")
)), )),
screenReaderAnnounceInlineSuggestion: register(new EditorBooleanOption(
EditorOption.screenReaderAnnounceInlineSuggestion, 'screenReaderAnnounceInlineSuggestion', false,
{
description: nls.localize('screenReaderAnnounceInlineSuggestion', "Control whether inline suggestions are announced by a screen reader. Note that this does not work on MacOS with VoiceOver."),
tags: ['accessibility']
}
)),
autoClosingBrackets: register(new EditorStringEnumOption( autoClosingBrackets: register(new EditorStringEnumOption(
EditorOption.autoClosingBrackets, 'autoClosingBrackets', EditorOption.autoClosingBrackets, 'autoClosingBrackets',
'languageDefined' as 'always' | 'languageDefined' | 'beforeWhitespace' | 'never', 'languageDefined' as 'always' | 'languageDefined' | 'beforeWhitespace' | 'never',

View File

@@ -179,140 +179,141 @@ export enum EditorOption {
accessibilityPageSize = 3, accessibilityPageSize = 3,
ariaLabel = 4, ariaLabel = 4,
autoClosingBrackets = 5, autoClosingBrackets = 5,
autoClosingDelete = 6, screenReaderAnnounceInlineSuggestion = 6,
autoClosingOvertype = 7, autoClosingDelete = 7,
autoClosingQuotes = 8, autoClosingOvertype = 8,
autoIndent = 9, autoClosingQuotes = 9,
automaticLayout = 10, autoIndent = 10,
autoSurround = 11, automaticLayout = 11,
bracketPairColorization = 12, autoSurround = 12,
guides = 13, bracketPairColorization = 13,
codeLens = 14, guides = 14,
codeLensFontFamily = 15, codeLens = 15,
codeLensFontSize = 16, codeLensFontFamily = 16,
colorDecorators = 17, codeLensFontSize = 17,
colorDecoratorsLimit = 18, colorDecorators = 18,
columnSelection = 19, colorDecoratorsLimit = 19,
comments = 20, columnSelection = 20,
contextmenu = 21, comments = 21,
copyWithSyntaxHighlighting = 22, contextmenu = 22,
cursorBlinking = 23, copyWithSyntaxHighlighting = 23,
cursorSmoothCaretAnimation = 24, cursorBlinking = 24,
cursorStyle = 25, cursorSmoothCaretAnimation = 25,
cursorSurroundingLines = 26, cursorStyle = 26,
cursorSurroundingLinesStyle = 27, cursorSurroundingLines = 27,
cursorWidth = 28, cursorSurroundingLinesStyle = 28,
disableLayerHinting = 29, cursorWidth = 29,
disableMonospaceOptimizations = 30, disableLayerHinting = 30,
domReadOnly = 31, disableMonospaceOptimizations = 31,
dragAndDrop = 32, domReadOnly = 32,
dropIntoEditor = 33, dragAndDrop = 33,
emptySelectionClipboard = 34, dropIntoEditor = 34,
experimentalWhitespaceRendering = 35, emptySelectionClipboard = 35,
extraEditorClassName = 36, experimentalWhitespaceRendering = 36,
fastScrollSensitivity = 37, extraEditorClassName = 37,
find = 38, fastScrollSensitivity = 38,
fixedOverflowWidgets = 39, find = 39,
folding = 40, fixedOverflowWidgets = 40,
foldingStrategy = 41, folding = 41,
foldingHighlight = 42, foldingStrategy = 42,
foldingImportsByDefault = 43, foldingHighlight = 43,
foldingMaximumRegions = 44, foldingImportsByDefault = 44,
unfoldOnClickAfterEndOfLine = 45, foldingMaximumRegions = 45,
fontFamily = 46, unfoldOnClickAfterEndOfLine = 46,
fontInfo = 47, fontFamily = 47,
fontLigatures = 48, fontInfo = 48,
fontSize = 49, fontLigatures = 49,
fontWeight = 50, fontSize = 50,
fontVariations = 51, fontWeight = 51,
formatOnPaste = 52, fontVariations = 52,
formatOnType = 53, formatOnPaste = 53,
glyphMargin = 54, formatOnType = 54,
gotoLocation = 55, glyphMargin = 55,
hideCursorInOverviewRuler = 56, gotoLocation = 56,
hover = 57, hideCursorInOverviewRuler = 57,
inDiffEditor = 58, hover = 58,
inlineSuggest = 59, inDiffEditor = 59,
letterSpacing = 60, inlineSuggest = 60,
lightbulb = 61, letterSpacing = 61,
lineDecorationsWidth = 62, lightbulb = 62,
lineHeight = 63, lineDecorationsWidth = 63,
lineNumbers = 64, lineHeight = 64,
lineNumbersMinChars = 65, lineNumbers = 65,
linkedEditing = 66, lineNumbersMinChars = 66,
links = 67, linkedEditing = 67,
matchBrackets = 68, links = 68,
minimap = 69, matchBrackets = 69,
mouseStyle = 70, minimap = 70,
mouseWheelScrollSensitivity = 71, mouseStyle = 71,
mouseWheelZoom = 72, mouseWheelScrollSensitivity = 72,
multiCursorMergeOverlapping = 73, mouseWheelZoom = 73,
multiCursorModifier = 74, multiCursorMergeOverlapping = 74,
multiCursorPaste = 75, multiCursorModifier = 75,
multiCursorLimit = 76, multiCursorPaste = 76,
occurrencesHighlight = 77, multiCursorLimit = 77,
overviewRulerBorder = 78, occurrencesHighlight = 78,
overviewRulerLanes = 79, overviewRulerBorder = 79,
padding = 80, overviewRulerLanes = 80,
parameterHints = 81, padding = 81,
peekWidgetDefaultFocus = 82, parameterHints = 82,
definitionLinkOpensInPeek = 83, peekWidgetDefaultFocus = 83,
quickSuggestions = 84, definitionLinkOpensInPeek = 84,
quickSuggestionsDelay = 85, quickSuggestions = 85,
readOnly = 86, quickSuggestionsDelay = 86,
renameOnType = 87, readOnly = 87,
renderControlCharacters = 88, renameOnType = 88,
renderFinalNewline = 89, renderControlCharacters = 89,
renderLineHighlight = 90, renderFinalNewline = 90,
renderLineHighlightOnlyWhenFocus = 91, renderLineHighlight = 91,
renderValidationDecorations = 92, renderLineHighlightOnlyWhenFocus = 92,
renderWhitespace = 93, renderValidationDecorations = 93,
revealHorizontalRightPadding = 94, renderWhitespace = 94,
roundedSelection = 95, revealHorizontalRightPadding = 95,
rulers = 96, roundedSelection = 96,
scrollbar = 97, rulers = 97,
scrollBeyondLastColumn = 98, scrollbar = 98,
scrollBeyondLastLine = 99, scrollBeyondLastColumn = 99,
scrollPredominantAxis = 100, scrollBeyondLastLine = 100,
selectionClipboard = 101, scrollPredominantAxis = 101,
selectionHighlight = 102, selectionClipboard = 102,
selectOnLineNumbers = 103, selectionHighlight = 103,
showFoldingControls = 104, selectOnLineNumbers = 104,
showUnused = 105, showFoldingControls = 105,
snippetSuggestions = 106, showUnused = 106,
smartSelect = 107, snippetSuggestions = 107,
smoothScrolling = 108, smartSelect = 108,
stickyScroll = 109, smoothScrolling = 109,
stickyTabStops = 110, stickyScroll = 110,
stopRenderingLineAfter = 111, stickyTabStops = 111,
suggest = 112, stopRenderingLineAfter = 112,
suggestFontSize = 113, suggest = 113,
suggestLineHeight = 114, suggestFontSize = 114,
suggestOnTriggerCharacters = 115, suggestLineHeight = 115,
suggestSelection = 116, suggestOnTriggerCharacters = 116,
tabCompletion = 117, suggestSelection = 117,
tabIndex = 118, tabCompletion = 118,
unicodeHighlighting = 119, tabIndex = 119,
unusualLineTerminators = 120, unicodeHighlighting = 120,
useShadowDOM = 121, unusualLineTerminators = 121,
useTabStops = 122, useShadowDOM = 122,
wordBreak = 123, useTabStops = 123,
wordSeparators = 124, wordBreak = 124,
wordWrap = 125, wordSeparators = 125,
wordWrapBreakAfterCharacters = 126, wordWrap = 126,
wordWrapBreakBeforeCharacters = 127, wordWrapBreakAfterCharacters = 127,
wordWrapColumn = 128, wordWrapBreakBeforeCharacters = 128,
wordWrapOverride1 = 129, wordWrapColumn = 129,
wordWrapOverride2 = 130, wordWrapOverride1 = 130,
wrappingIndent = 131, wordWrapOverride2 = 131,
wrappingStrategy = 132, wrappingIndent = 132,
showDeprecated = 133, wrappingStrategy = 133,
inlayHints = 134, showDeprecated = 134,
editorClassName = 135, inlayHints = 135,
pixelRatio = 136, editorClassName = 136,
tabFocusMode = 137, pixelRatio = 137,
layoutInfo = 138, tabFocusMode = 138,
wrappingInfo = 139 layoutInfo = 139,
wrappingInfo = 140
} }
/** /**

View File

@@ -22,6 +22,8 @@ import { RenderLineInput, renderViewLine } from 'vs/editor/common/viewLayout/vie
import { InlineDecorationType } from 'vs/editor/common/viewModel'; import { InlineDecorationType } from 'vs/editor/common/viewModel';
import { GhostTextReplacement, GhostTextWidgetModel } from 'vs/editor/contrib/inlineCompletions/browser/ghostText'; import { GhostTextReplacement, GhostTextWidgetModel } from 'vs/editor/contrib/inlineCompletions/browser/ghostText';
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation'; import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
import { alert } from 'vs/base/browser/ui/aria/aria';
import { AudioCue, IAudioCueService } from 'vs/platform/audioCues/browser/audioCueService';
const ttPolicy = window.trustedTypes?.createPolicy('editorGhostText', { createHTML: value => value }); const ttPolicy = window.trustedTypes?.createPolicy('editorGhostText', { createHTML: value => value });
@@ -36,6 +38,7 @@ export class GhostTextWidget extends Disposable {
private readonly model: GhostTextWidgetModel, private readonly model: GhostTextWidgetModel,
@IInstantiationService private readonly instantiationService: IInstantiationService, @IInstantiationService private readonly instantiationService: IInstantiationService,
@ILanguageService private readonly languageService: ILanguageService, @ILanguageService private readonly languageService: ILanguageService,
@IAudioCueService private readonly audioCueService: IAudioCueService
) { ) {
super(); super();
@@ -61,10 +64,8 @@ export class GhostTextWidget extends Disposable {
this.viewMoreContentWidget = undefined; this.viewMoreContentWidget = undefined;
})); }));
this._register(model.onDidChange(() => { this._register(model.onDidChange(() => this.update(true)));
this.update(); this.update(true);
}));
this.update();
} }
public shouldShowHoverAtViewZone(viewZoneId: string): boolean { public shouldShowHoverAtViewZone(viewZoneId: string): boolean {
@@ -73,7 +74,7 @@ export class GhostTextWidget extends Disposable {
private readonly replacementDecoration = this._register(new DisposableDecorations(this.editor)); private readonly replacementDecoration = this._register(new DisposableDecorations(this.editor));
private update(): void { private update(notifyUser?: boolean): void {
const ghostText = this.model.ghostText; const ghostText = this.model.ghostText;
if (!this.editor.hasModel() || !ghostText || this.disposed) { if (!this.editor.hasModel() || !ghostText || this.disposed) {
@@ -157,6 +158,17 @@ export class GhostTextWidget extends Disposable {
hiddenTextStartColumn !== undefined ? { column: hiddenTextStartColumn, length: textBufferLine.length + 1 - hiddenTextStartColumn } : undefined); hiddenTextStartColumn !== undefined ? { column: hiddenTextStartColumn, length: textBufferLine.length + 1 - hiddenTextStartColumn } : undefined);
this.additionalLinesWidget.updateLines(ghostText.lineNumber, additionalLines, ghostText.additionalReservedLineCount); this.additionalLinesWidget.updateLines(ghostText.lineNumber, additionalLines, ghostText.additionalReservedLineCount);
if (notifyUser) {
this.audioCueService.playAudioCue(AudioCue.inlineSuggestion).then(() => {
if (this.editor.getOption(EditorOption.screenReaderAnnounceInlineSuggestion)) {
const lineText = this.editor.getModel()?.getLineContent(ghostText.lineNumber);
if (lineText) {
alert(ghostText.renderForScreenReader(lineText));
}
}
});
}
if (0 < 0) { if (0 < 0) {
// Not supported at the moment, condition is always false. // Not supported at the moment, condition is always false.
this.viewMoreContentWidget = this.renderViewMoreLines( this.viewMoreContentWidget = this.renderViewMoreLines(

274
src/vs/monaco.d.ts vendored
View File

@@ -3029,6 +3029,10 @@ declare namespace monaco.editor {
* The aria label for the editor's textarea (when it is focused). * The aria label for the editor's textarea (when it is focused).
*/ */
ariaLabel?: string; ariaLabel?: string;
/**
* Control whether a screen reader announces inline suggestion content immediately.
*/
screenReaderAnnounceInlineSuggestion?: boolean;
/** /**
* The `tabindex` property of the editor's textarea * The `tabindex` property of the editor's textarea
*/ */
@@ -4589,140 +4593,141 @@ declare namespace monaco.editor {
accessibilityPageSize = 3, accessibilityPageSize = 3,
ariaLabel = 4, ariaLabel = 4,
autoClosingBrackets = 5, autoClosingBrackets = 5,
autoClosingDelete = 6, screenReaderAnnounceInlineSuggestion = 6,
autoClosingOvertype = 7, autoClosingDelete = 7,
autoClosingQuotes = 8, autoClosingOvertype = 8,
autoIndent = 9, autoClosingQuotes = 9,
automaticLayout = 10, autoIndent = 10,
autoSurround = 11, automaticLayout = 11,
bracketPairColorization = 12, autoSurround = 12,
guides = 13, bracketPairColorization = 13,
codeLens = 14, guides = 14,
codeLensFontFamily = 15, codeLens = 15,
codeLensFontSize = 16, codeLensFontFamily = 16,
colorDecorators = 17, codeLensFontSize = 17,
colorDecoratorsLimit = 18, colorDecorators = 18,
columnSelection = 19, colorDecoratorsLimit = 19,
comments = 20, columnSelection = 20,
contextmenu = 21, comments = 21,
copyWithSyntaxHighlighting = 22, contextmenu = 22,
cursorBlinking = 23, copyWithSyntaxHighlighting = 23,
cursorSmoothCaretAnimation = 24, cursorBlinking = 24,
cursorStyle = 25, cursorSmoothCaretAnimation = 25,
cursorSurroundingLines = 26, cursorStyle = 26,
cursorSurroundingLinesStyle = 27, cursorSurroundingLines = 27,
cursorWidth = 28, cursorSurroundingLinesStyle = 28,
disableLayerHinting = 29, cursorWidth = 29,
disableMonospaceOptimizations = 30, disableLayerHinting = 30,
domReadOnly = 31, disableMonospaceOptimizations = 31,
dragAndDrop = 32, domReadOnly = 32,
dropIntoEditor = 33, dragAndDrop = 33,
emptySelectionClipboard = 34, dropIntoEditor = 34,
experimentalWhitespaceRendering = 35, emptySelectionClipboard = 35,
extraEditorClassName = 36, experimentalWhitespaceRendering = 36,
fastScrollSensitivity = 37, extraEditorClassName = 37,
find = 38, fastScrollSensitivity = 38,
fixedOverflowWidgets = 39, find = 39,
folding = 40, fixedOverflowWidgets = 40,
foldingStrategy = 41, folding = 41,
foldingHighlight = 42, foldingStrategy = 42,
foldingImportsByDefault = 43, foldingHighlight = 43,
foldingMaximumRegions = 44, foldingImportsByDefault = 44,
unfoldOnClickAfterEndOfLine = 45, foldingMaximumRegions = 45,
fontFamily = 46, unfoldOnClickAfterEndOfLine = 46,
fontInfo = 47, fontFamily = 47,
fontLigatures = 48, fontInfo = 48,
fontSize = 49, fontLigatures = 49,
fontWeight = 50, fontSize = 50,
fontVariations = 51, fontWeight = 51,
formatOnPaste = 52, fontVariations = 52,
formatOnType = 53, formatOnPaste = 53,
glyphMargin = 54, formatOnType = 54,
gotoLocation = 55, glyphMargin = 55,
hideCursorInOverviewRuler = 56, gotoLocation = 56,
hover = 57, hideCursorInOverviewRuler = 57,
inDiffEditor = 58, hover = 58,
inlineSuggest = 59, inDiffEditor = 59,
letterSpacing = 60, inlineSuggest = 60,
lightbulb = 61, letterSpacing = 61,
lineDecorationsWidth = 62, lightbulb = 62,
lineHeight = 63, lineDecorationsWidth = 63,
lineNumbers = 64, lineHeight = 64,
lineNumbersMinChars = 65, lineNumbers = 65,
linkedEditing = 66, lineNumbersMinChars = 66,
links = 67, linkedEditing = 67,
matchBrackets = 68, links = 68,
minimap = 69, matchBrackets = 69,
mouseStyle = 70, minimap = 70,
mouseWheelScrollSensitivity = 71, mouseStyle = 71,
mouseWheelZoom = 72, mouseWheelScrollSensitivity = 72,
multiCursorMergeOverlapping = 73, mouseWheelZoom = 73,
multiCursorModifier = 74, multiCursorMergeOverlapping = 74,
multiCursorPaste = 75, multiCursorModifier = 75,
multiCursorLimit = 76, multiCursorPaste = 76,
occurrencesHighlight = 77, multiCursorLimit = 77,
overviewRulerBorder = 78, occurrencesHighlight = 78,
overviewRulerLanes = 79, overviewRulerBorder = 79,
padding = 80, overviewRulerLanes = 80,
parameterHints = 81, padding = 81,
peekWidgetDefaultFocus = 82, parameterHints = 82,
definitionLinkOpensInPeek = 83, peekWidgetDefaultFocus = 83,
quickSuggestions = 84, definitionLinkOpensInPeek = 84,
quickSuggestionsDelay = 85, quickSuggestions = 85,
readOnly = 86, quickSuggestionsDelay = 86,
renameOnType = 87, readOnly = 87,
renderControlCharacters = 88, renameOnType = 88,
renderFinalNewline = 89, renderControlCharacters = 89,
renderLineHighlight = 90, renderFinalNewline = 90,
renderLineHighlightOnlyWhenFocus = 91, renderLineHighlight = 91,
renderValidationDecorations = 92, renderLineHighlightOnlyWhenFocus = 92,
renderWhitespace = 93, renderValidationDecorations = 93,
revealHorizontalRightPadding = 94, renderWhitespace = 94,
roundedSelection = 95, revealHorizontalRightPadding = 95,
rulers = 96, roundedSelection = 96,
scrollbar = 97, rulers = 97,
scrollBeyondLastColumn = 98, scrollbar = 98,
scrollBeyondLastLine = 99, scrollBeyondLastColumn = 99,
scrollPredominantAxis = 100, scrollBeyondLastLine = 100,
selectionClipboard = 101, scrollPredominantAxis = 101,
selectionHighlight = 102, selectionClipboard = 102,
selectOnLineNumbers = 103, selectionHighlight = 103,
showFoldingControls = 104, selectOnLineNumbers = 104,
showUnused = 105, showFoldingControls = 105,
snippetSuggestions = 106, showUnused = 106,
smartSelect = 107, snippetSuggestions = 107,
smoothScrolling = 108, smartSelect = 108,
stickyScroll = 109, smoothScrolling = 109,
stickyTabStops = 110, stickyScroll = 110,
stopRenderingLineAfter = 111, stickyTabStops = 111,
suggest = 112, stopRenderingLineAfter = 112,
suggestFontSize = 113, suggest = 113,
suggestLineHeight = 114, suggestFontSize = 114,
suggestOnTriggerCharacters = 115, suggestLineHeight = 115,
suggestSelection = 116, suggestOnTriggerCharacters = 116,
tabCompletion = 117, suggestSelection = 117,
tabIndex = 118, tabCompletion = 118,
unicodeHighlighting = 119, tabIndex = 119,
unusualLineTerminators = 120, unicodeHighlighting = 120,
useShadowDOM = 121, unusualLineTerminators = 121,
useTabStops = 122, useShadowDOM = 122,
wordBreak = 123, useTabStops = 123,
wordSeparators = 124, wordBreak = 124,
wordWrap = 125, wordSeparators = 125,
wordWrapBreakAfterCharacters = 126, wordWrap = 126,
wordWrapBreakBeforeCharacters = 127, wordWrapBreakAfterCharacters = 127,
wordWrapColumn = 128, wordWrapBreakBeforeCharacters = 128,
wordWrapOverride1 = 129, wordWrapColumn = 129,
wordWrapOverride2 = 130, wordWrapOverride1 = 130,
wrappingIndent = 131, wordWrapOverride2 = 131,
wrappingStrategy = 132, wrappingIndent = 132,
showDeprecated = 133, wrappingStrategy = 133,
inlayHints = 134, showDeprecated = 134,
editorClassName = 135, inlayHints = 135,
pixelRatio = 136, editorClassName = 136,
tabFocusMode = 137, pixelRatio = 137,
layoutInfo = 138, tabFocusMode = 138,
wrappingInfo = 139 layoutInfo = 139,
wrappingInfo = 140
} }
export const EditorOptions: { export const EditorOptions: {
@@ -4731,6 +4736,7 @@ declare namespace monaco.editor {
accessibilitySupport: IEditorOption<EditorOption.accessibilitySupport, AccessibilitySupport>; accessibilitySupport: IEditorOption<EditorOption.accessibilitySupport, AccessibilitySupport>;
accessibilityPageSize: IEditorOption<EditorOption.accessibilityPageSize, number>; accessibilityPageSize: IEditorOption<EditorOption.accessibilityPageSize, number>;
ariaLabel: IEditorOption<EditorOption.ariaLabel, string>; ariaLabel: IEditorOption<EditorOption.ariaLabel, string>;
screenReaderAnnounceInlineSuggestion: IEditorOption<EditorOption.screenReaderAnnounceInlineSuggestion, boolean>;
autoClosingBrackets: IEditorOption<EditorOption.autoClosingBrackets, 'always' | 'languageDefined' | 'beforeWhitespace' | 'never'>; autoClosingBrackets: IEditorOption<EditorOption.autoClosingBrackets, 'always' | 'languageDefined' | 'beforeWhitespace' | 'never'>;
autoClosingDelete: IEditorOption<EditorOption.autoClosingDelete, 'always' | 'never' | 'auto'>; autoClosingDelete: IEditorOption<EditorOption.autoClosingDelete, 'always' | 'never' | 'auto'>;
autoClosingOvertype: IEditorOption<EditorOption.autoClosingOvertype, 'always' | 'never' | 'auto'>; autoClosingOvertype: IEditorOption<EditorOption.autoClosingOvertype, 'always' | 'never' | 'auto'>;

View File

@@ -13,7 +13,6 @@ import { IMarkerService, MarkerSeverity } from 'vs/platform/markers/common/marke
import { FoldingController } from 'vs/editor/contrib/folding/browser/folding'; import { FoldingController } from 'vs/editor/contrib/folding/browser/folding';
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation'; import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
import { ITextModel } from 'vs/editor/common/model'; import { ITextModel } from 'vs/editor/common/model';
import { GhostTextController } from 'vs/editor/contrib/inlineCompletions/browser/ghostTextController';
import { CursorChangeReason } from 'vs/editor/common/cursorEvents'; import { CursorChangeReason } from 'vs/editor/common/cursorEvents';
import { autorun, autorunDelta, constObservable, debouncedObservable, derived, IObservable, observableFromEvent, observableFromPromise, wasEventTriggeredRecently } from 'vs/base/common/observable'; import { autorun, autorunDelta, constObservable, debouncedObservable, derived, IObservable, observableFromEvent, observableFromPromise, wasEventTriggeredRecently } from 'vs/base/common/observable';
import { AudioCue, IAudioCueService } from 'vs/platform/audioCues/browser/audioCueService'; import { AudioCue, IAudioCueService } from 'vs/platform/audioCues/browser/audioCueService';
@@ -31,7 +30,6 @@ export class AudioCueLineFeatureContribution
this.instantiationService.createInstance(MarkerLineFeature, AudioCue.warning, MarkerSeverity.Warning), this.instantiationService.createInstance(MarkerLineFeature, AudioCue.warning, MarkerSeverity.Warning),
this.instantiationService.createInstance(FoldedAreaLineFeature), this.instantiationService.createInstance(FoldedAreaLineFeature),
this.instantiationService.createInstance(BreakpointLineFeature), this.instantiationService.createInstance(BreakpointLineFeature),
this.instantiationService.createInstance(InlineCompletionLineFeature),
]; ];
private readonly isEnabledCache = new CachedFunction<AudioCue, IObservable<boolean>>((cue) => observableFromEvent( private readonly isEnabledCache = new CachedFunction<AudioCue, IObservable<boolean>>((cue) => observableFromEvent(
@@ -258,37 +256,3 @@ class BreakpointLineFeature implements LineFeature {
); );
} }
} }
class InlineCompletionLineFeature implements LineFeature {
public readonly audioCue = AudioCue.inlineSuggestion;
getObservableState(editor: ICodeEditor, _model: ITextModel): IObservable<LineFeatureState> {
const ghostTextController = GhostTextController.get(editor);
if (!ghostTextController) {
return constObservable<LineFeatureState>({
isPresent: () => false,
});
}
const activeGhostText = observableFromEvent(
ghostTextController.onActiveModelDidChange,
() => /** @description ghostTextController.onActiveModelDidChange */ ghostTextController.activeModel
).map((activeModel) => (
activeModel
? observableFromEvent(
activeModel.inlineCompletionsModel.onDidChange,
() => /** @description activeModel.inlineCompletionsModel.onDidChange */ activeModel.inlineCompletionsModel.ghostText
)
: undefined
));
return derived<LineFeatureState>('ghostText', reader => {
const ghostText = activeGhostText.read(reader)?.read(reader);
return {
isPresent(position) {
return ghostText?.lineNumber === position.lineNumber;
}
};
});
}
}