mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-17 02:51:36 -05:00
Merge from vscode a416c77e56ef0314ae00633faa04878151610de8 (#8600)
* Merge from vscode a416c77e56ef0314ae00633faa04878151610de8 * distro * fix tests * fix tests
This commit is contained in:
@@ -263,6 +263,13 @@ function migrateOptions(options: IEditorOptions): void {
|
||||
} else if (<any>autoIndent === false) {
|
||||
options.autoIndent = 'advanced';
|
||||
}
|
||||
|
||||
const matchBrackets = options.matchBrackets;
|
||||
if (<any>matchBrackets === true) {
|
||||
options.matchBrackets = 'always';
|
||||
} else if (<any>matchBrackets === false) {
|
||||
options.matchBrackets = 'never';
|
||||
}
|
||||
}
|
||||
|
||||
function deepCloneAndMigrateOptions(_options: IEditorOptions): IEditorOptions {
|
||||
|
||||
@@ -481,9 +481,9 @@ export interface IEditorOptions {
|
||||
showFoldingControls?: 'always' | 'mouseover';
|
||||
/**
|
||||
* Enable highlighting of matching brackets.
|
||||
* Defaults to true.
|
||||
* Defaults to 'always'.
|
||||
*/
|
||||
matchBrackets?: boolean;
|
||||
matchBrackets?: 'never' | 'near' | 'always';
|
||||
/**
|
||||
* Enable rendering of whitespace.
|
||||
* Defaults to none.
|
||||
@@ -2277,7 +2277,7 @@ class EditorRulers extends SimpleEditorOption<EditorOption.rulers, number[]> {
|
||||
for (let value of input) {
|
||||
rulers.push(EditorIntOption.clampedInt(value, 0, 0, 10000));
|
||||
}
|
||||
rulers.sort();
|
||||
rulers.sort((a, b) => a - b);
|
||||
return rulers;
|
||||
}
|
||||
return this.defaultValue;
|
||||
@@ -3364,9 +3364,11 @@ export const EditorOptions = {
|
||||
EditorOption.links, 'links', true,
|
||||
{ description: nls.localize('links', "Controls whether the editor should detect links and make them clickable.") }
|
||||
)),
|
||||
matchBrackets: register(new EditorBooleanOption(
|
||||
EditorOption.matchBrackets, 'matchBrackets', true,
|
||||
{ description: nls.localize('matchBrackets', "Highlight matching brackets when one of them is selected.") }
|
||||
matchBrackets: register(new EditorStringEnumOption(
|
||||
EditorOption.matchBrackets, 'matchBrackets',
|
||||
'always' as 'never' | 'near' | 'always',
|
||||
['always', 'near', 'never'] as const,
|
||||
{ description: nls.localize('matchBrackets', "Highlight matching brackets.") }
|
||||
)),
|
||||
minimap: register(new EditorMinimap()),
|
||||
mouseStyle: register(new EditorStringEnumOption(
|
||||
|
||||
@@ -898,7 +898,7 @@ export interface ITextModel {
|
||||
* @param position The position at which to start the search.
|
||||
* @internal
|
||||
*/
|
||||
findEnclosingBrackets(position: IPosition): [Range, Range] | null;
|
||||
findEnclosingBrackets(position: IPosition, maxDuration?: number): [Range, Range] | null;
|
||||
|
||||
/**
|
||||
* Given a `position`, if the position is on top or near a bracket,
|
||||
|
||||
@@ -34,6 +34,7 @@ import { withUndefinedAsNull } from 'vs/base/common/types';
|
||||
import { VSBufferReadableStream, VSBuffer } from 'vs/base/common/buffer';
|
||||
import { TokensStore, MultilineTokens, countEOL, MultilineTokens2, TokensStore2 } from 'vs/editor/common/model/tokensStore';
|
||||
import { Color } from 'vs/base/common/color';
|
||||
import { Constants } from 'vs/base/common/uint';
|
||||
|
||||
function createTextBufferBuilder() {
|
||||
return new PieceTreeTextBufferBuilder();
|
||||
@@ -2341,16 +2342,21 @@ export class TextModel extends Disposable implements model.ITextModel {
|
||||
return null;
|
||||
}
|
||||
|
||||
public findEnclosingBrackets(_position: IPosition): [Range, Range] | null {
|
||||
public findEnclosingBrackets(_position: IPosition, maxDuration = Constants.MAX_SAFE_SMALL_INTEGER): [Range, Range] | null {
|
||||
const position = this.validatePosition(_position);
|
||||
const lineCount = this.getLineCount();
|
||||
const savedCounts = new Map<number, number[]>();
|
||||
|
||||
let counts: number[] = [];
|
||||
const resetCounts = (modeBrackets: RichEditBrackets | null) => {
|
||||
counts = [];
|
||||
for (let i = 0, len = modeBrackets ? modeBrackets.brackets.length : 0; i < len; i++) {
|
||||
counts[i] = 0;
|
||||
const resetCounts = (languageId: number, modeBrackets: RichEditBrackets | null) => {
|
||||
if (!savedCounts.has(languageId)) {
|
||||
let tmp = [];
|
||||
for (let i = 0, len = modeBrackets ? modeBrackets.brackets.length : 0; i < len; i++) {
|
||||
tmp[i] = 0;
|
||||
}
|
||||
savedCounts.set(languageId, tmp);
|
||||
}
|
||||
counts = savedCounts.get(languageId)!;
|
||||
};
|
||||
const searchInRange = (modeBrackets: RichEditBrackets, lineNumber: number, lineText: string, searchStartOffset: number, searchEndOffset: number): [Range, Range] | null => {
|
||||
while (true) {
|
||||
@@ -2380,7 +2386,12 @@ export class TextModel extends Disposable implements model.ITextModel {
|
||||
|
||||
let languageId: LanguageId = -1;
|
||||
let modeBrackets: RichEditBrackets | null = null;
|
||||
const startTime = Date.now();
|
||||
for (let lineNumber = position.lineNumber; lineNumber <= lineCount; lineNumber++) {
|
||||
const elapsedTime = Date.now() - startTime;
|
||||
if (elapsedTime > maxDuration) {
|
||||
return null;
|
||||
}
|
||||
const lineTokens = this._getLineTokens(lineNumber);
|
||||
const tokenCount = lineTokens.getCount();
|
||||
const lineText = this._buffer.getLineContent(lineNumber);
|
||||
@@ -2396,7 +2407,7 @@ export class TextModel extends Disposable implements model.ITextModel {
|
||||
if (languageId !== tokenLanguageId) {
|
||||
languageId = tokenLanguageId;
|
||||
modeBrackets = LanguageConfigurationRegistry.getBracketsSupport(languageId);
|
||||
resetCounts(modeBrackets);
|
||||
resetCounts(languageId, modeBrackets);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2415,7 +2426,7 @@ export class TextModel extends Disposable implements model.ITextModel {
|
||||
}
|
||||
languageId = tokenLanguageId;
|
||||
modeBrackets = LanguageConfigurationRegistry.getBracketsSupport(languageId);
|
||||
resetCounts(modeBrackets);
|
||||
resetCounts(languageId, modeBrackets);
|
||||
}
|
||||
|
||||
const searchInToken = (!!modeBrackets && !ignoreBracketsInToken(lineTokens.getStandardTokenType(tokenIndex)));
|
||||
|
||||
@@ -121,7 +121,7 @@ export interface IEncodedTokens {
|
||||
getMetadata(tokenIndex: number): number;
|
||||
|
||||
clear(): void;
|
||||
acceptDeleteRange(startDeltaLine: number, startCharacter: number, endDeltaLine: number, endCharacter: number): void;
|
||||
acceptDeleteRange(horizontalShiftForFirstLineTokens: number, startDeltaLine: number, startCharacter: number, endDeltaLine: number, endCharacter: number): void;
|
||||
acceptInsertText(deltaLine: number, character: number, eolCount: number, firstLineLength: number, lastLineLength: number, firstCharCode: number): void;
|
||||
}
|
||||
|
||||
@@ -173,7 +173,7 @@ export class SparseEncodedTokens implements IEncodedTokens {
|
||||
this._tokenCount = 0;
|
||||
}
|
||||
|
||||
public acceptDeleteRange(startDeltaLine: number, startCharacter: number, endDeltaLine: number, endCharacter: number): void {
|
||||
public acceptDeleteRange(horizontalShiftForFirstLineTokens: number, startDeltaLine: number, startCharacter: number, endDeltaLine: number, endCharacter: number): void {
|
||||
// This is a bit complex, here are the cases I used to think about this:
|
||||
//
|
||||
// 1. The token starts before the deletion range
|
||||
@@ -292,9 +292,13 @@ export class SparseEncodedTokens implements IEncodedTokens {
|
||||
tokenDeltaLine -= deletedLineCount;
|
||||
} else if (tokenDeltaLine === endDeltaLine && tokenStartCharacter >= endCharacter) {
|
||||
// 4. (continued) The token starts after the deletion range, on the last line where a deletion occurs
|
||||
if (horizontalShiftForFirstLineTokens && tokenDeltaLine === 0) {
|
||||
tokenStartCharacter += horizontalShiftForFirstLineTokens;
|
||||
tokenEndCharacter += horizontalShiftForFirstLineTokens;
|
||||
}
|
||||
tokenDeltaLine -= deletedLineCount;
|
||||
tokenStartCharacter -= endCharacter;
|
||||
tokenEndCharacter -= endCharacter;
|
||||
tokenStartCharacter -= (endCharacter - startCharacter);
|
||||
tokenEndCharacter -= (endCharacter - startCharacter);
|
||||
} else {
|
||||
throw new Error(`Not possible!`);
|
||||
}
|
||||
@@ -373,8 +377,8 @@ export class SparseEncodedTokens implements IEncodedTokens {
|
||||
}
|
||||
}
|
||||
// => the token must move and keep its size constant
|
||||
tokenDeltaLine += eolCount;
|
||||
if (tokenDeltaLine === deltaLine) {
|
||||
tokenDeltaLine += eolCount;
|
||||
// this token is on the line where the insertion is taking place
|
||||
if (eolCount === 0) {
|
||||
tokenStartCharacter += firstLineLength;
|
||||
@@ -384,6 +388,8 @@ export class SparseEncodedTokens implements IEncodedTokens {
|
||||
tokenStartCharacter = lastLineLength + (tokenStartCharacter - character);
|
||||
tokenEndCharacter = tokenStartCharacter + tokenLength;
|
||||
}
|
||||
} else {
|
||||
tokenDeltaLine += eolCount;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -527,9 +533,9 @@ export class MultilineTokens2 {
|
||||
const deletedBefore = -firstLineIndex;
|
||||
this.startLineNumber -= deletedBefore;
|
||||
|
||||
this.tokens.acceptDeleteRange(0, 0, lastLineIndex, range.endColumn - 1);
|
||||
this.tokens.acceptDeleteRange(range.startColumn - 1, 0, 0, lastLineIndex, range.endColumn - 1);
|
||||
} else {
|
||||
this.tokens.acceptDeleteRange(firstLineIndex, range.startColumn - 1, lastLineIndex, range.endColumn - 1);
|
||||
this.tokens.acceptDeleteRange(0, firstLineIndex, range.startColumn - 1, lastLineIndex, range.endColumn - 1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -652,11 +652,15 @@ class ModelSemanticColoring extends Disposable {
|
||||
this._isDisposed = false;
|
||||
this._model = model;
|
||||
this._semanticStyling = stylingProvider;
|
||||
this._fetchSemanticTokens = this._register(new RunOnceScheduler(() => this._fetchSemanticTokensNow(), 500));
|
||||
this._fetchSemanticTokens = this._register(new RunOnceScheduler(() => this._fetchSemanticTokensNow(), 300));
|
||||
this._currentResponse = null;
|
||||
this._currentRequestCancellationTokenSource = null;
|
||||
|
||||
this._register(this._model.onDidChangeContent(e => this._fetchSemanticTokens.schedule()));
|
||||
this._register(this._model.onDidChangeContent(e => {
|
||||
if (!this._fetchSemanticTokens.isScheduled()) {
|
||||
this._fetchSemanticTokens.schedule();
|
||||
}
|
||||
}));
|
||||
this._register(SemanticTokensProviderRegistry.onDidChange(e => this._fetchSemanticTokens.schedule()));
|
||||
if (themeService) {
|
||||
// workaround for tests which use undefined... :/
|
||||
@@ -887,7 +891,9 @@ class ModelSemanticColoring extends Disposable {
|
||||
}
|
||||
}
|
||||
|
||||
this._fetchSemanticTokens.schedule();
|
||||
if (!this._fetchSemanticTokens.isScheduled()) {
|
||||
this._fetchSemanticTokens.schedule();
|
||||
}
|
||||
}
|
||||
|
||||
this._model.setSemanticTokens(result);
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
import * as nls from 'vs/nls';
|
||||
import { Color, RGBA } from 'vs/base/common/color';
|
||||
import { activeContrastBorder, editorBackground, editorForeground, registerColor, editorWarningForeground, editorInfoForeground, editorWarningBorder, editorInfoBorder, contrastBorder } from 'vs/platform/theme/common/colorRegistry';
|
||||
import { activeContrastBorder, editorBackground, editorForeground, registerColor, editorWarningForeground, editorInfoForeground, editorWarningBorder, editorInfoBorder, contrastBorder, editorFindMatchHighlight } from 'vs/platform/theme/common/colorRegistry';
|
||||
import { registerThemingParticipant } from 'vs/platform/theme/common/themeService';
|
||||
|
||||
/**
|
||||
@@ -15,7 +15,7 @@ export const editorLineHighlight = registerColor('editor.lineHighlightBackground
|
||||
export const editorLineHighlightBorder = registerColor('editor.lineHighlightBorder', { dark: '#282828', light: '#eeeeee', hc: '#f38518' }, nls.localize('lineHighlightBorderBox', 'Background color for the border around the line at the cursor position.'));
|
||||
export const editorRangeHighlight = registerColor('editor.rangeHighlightBackground', { dark: '#ffffff0b', light: '#fdff0033', hc: null }, nls.localize('rangeHighlight', 'Background color of highlighted ranges, like by quick open and find features. The color must not be opaque so as not to hide underlying decorations.'), true);
|
||||
export const editorRangeHighlightBorder = registerColor('editor.rangeHighlightBorder', { dark: null, light: null, hc: activeContrastBorder }, nls.localize('rangeHighlightBorder', 'Background color of the border around highlighted ranges.'), true);
|
||||
export const editorSymbolHighlight = registerColor('editor.symbolHighlightBackground', { dark: editorRangeHighlight, light: editorRangeHighlight, hc: null }, nls.localize('symbolHighlight', 'Background color of highlighted symbol, like for go to definition or go next/previous symbol. The color must not be opaque so as not to hide underlying decorations.'), true);
|
||||
export const editorSymbolHighlight = registerColor('editor.symbolHighlightBackground', { dark: editorFindMatchHighlight, light: editorFindMatchHighlight, hc: null }, nls.localize('symbolHighlight', 'Background color of highlighted symbol, like for go to definition or go next/previous symbol. The color must not be opaque so as not to hide underlying decorations.'), true);
|
||||
export const editorSymbolHighlightBorder = registerColor('editor.symbolHighlightBorder', { dark: null, light: null, hc: activeContrastBorder }, nls.localize('symbolHighlightBorder', 'Background color of the border around highlighted symbols.'), true);
|
||||
|
||||
export const editorCursorForeground = registerColor('editorCursor.foreground', { dark: '#AEAFAD', light: Color.black, hc: Color.white }, nls.localize('caret', 'Color of the editor cursor.'));
|
||||
|
||||
Reference in New Issue
Block a user