提交 2f367a51 编写于 作者: I isidor

A11Y in f7: go to next symbol

fixes #91706
上级 a250df70
......@@ -18,7 +18,7 @@ import { Range } from 'vs/editor/common/core/range';
import { Selection } from 'vs/editor/common/core/selection';
import { IEditorContribution } from 'vs/editor/common/editorCommon';
import { EditorContextKeys } from 'vs/editor/common/editorContextKeys';
import { IModelDeltaDecoration, ITextModel, OverviewRulerLane, TrackedRangeStickiness } from 'vs/editor/common/model';
import { IModelDeltaDecoration, ITextModel, OverviewRulerLane, TrackedRangeStickiness, IWordAtPosition } from 'vs/editor/common/model';
import { ModelDecorationOptions } from 'vs/editor/common/model/textModel';
import { DocumentHighlight, DocumentHighlightKind, DocumentHighlightProviderRegistry } from 'vs/editor/common/modes';
import { IContextKey, IContextKeyService, RawContextKey } from 'vs/platform/contextkey/common/contextkey';
......@@ -27,6 +27,7 @@ import { KeybindingWeight } from 'vs/platform/keybinding/common/keybindingsRegis
import { activeContrastBorder, editorSelectionHighlight, editorSelectionHighlightBorder, overviewRulerSelectionHighlightForeground, registerColor } from 'vs/platform/theme/common/colorRegistry';
import { registerThemingParticipant, themeColorFromId } from 'vs/platform/theme/common/themeService';
import { EditorOption } from 'vs/editor/common/config/editorOptions';
import { alert } from 'vs/base/browser/ui/aria/aria';
const editorWordHighlight = registerColor('editor.wordHighlightBackground', { dark: '#575757B8', light: '#57575740', hc: null }, nls.localize('wordHighlight', 'Background color of a symbol during read-access, like reading a variable. The color must not be opaque so as not to hide underlying decorations.'), true);
const editorWordHighlightStrong = registerColor('editor.wordHighlightStrongBackground', { dark: '#004972B8', light: '#0e639c40', hc: null }, nls.localize('wordHighlightStrong', 'Background color of a symbol during write-access, like writing to a variable. The color must not be opaque so as not to hide underlying decorations.'), true);
......@@ -245,6 +246,11 @@ class WordHighlighter {
this._ignorePositionChangeEvent = true;
this.editor.setPosition(dest.getStartPosition());
this.editor.revealRangeInCenterIfOutsideViewport(dest);
const word = this._getWord();
if (word) {
const lineContent = this.editor.getModel().getLineContent(dest.startLineNumber);
alert(`${lineContent}, ${newIndex + 1} of ${highlights.length} for '${word.word}'`);
}
} finally {
this._ignorePositionChangeEvent = false;
}
......@@ -259,6 +265,11 @@ class WordHighlighter {
this._ignorePositionChangeEvent = true;
this.editor.setPosition(dest.getStartPosition());
this.editor.revealRangeInCenterIfOutsideViewport(dest);
const word = this._getWord();
if (word) {
const lineContent = this.editor.getModel().getLineContent(dest.startLineNumber);
alert(`${lineContent}, ${newIndex + 1} of ${highlights.length} for '${word.word}'`);
}
} finally {
this._ignorePositionChangeEvent = false;
}
......@@ -312,6 +323,17 @@ class WordHighlighter {
this._run();
}
private _getWord(): IWordAtPosition | null {
let editorSelection = this.editor.getSelection();
let lineNumber = editorSelection.startLineNumber;
let startColumn = editorSelection.startColumn;
return this.model.getWordAtPosition({
lineNumber: lineNumber,
column: startColumn
});
}
private _run(): void {
let editorSelection = this.editor.getSelection();
......@@ -321,14 +343,10 @@ class WordHighlighter {
return;
}
let lineNumber = editorSelection.startLineNumber;
let startColumn = editorSelection.startColumn;
let endColumn = editorSelection.endColumn;
let word = this.model.getWordAtPosition({
lineNumber: lineNumber,
column: startColumn
});
const word = this._getWord();
// The selection must be inside a word or surround one word at most
if (!word || word.startColumn > startColumn || word.endColumn < endColumn) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册