Merge from vscode 2e5312cd61ff99c570299ecc122c52584265eda2

This commit is contained in:
ADS Merger
2020-04-23 02:50:35 +00:00
committed by Anthony Dresser
parent 3603f55d97
commit 7f1d8fc32f
659 changed files with 22709 additions and 12497 deletions

View File

@@ -1073,7 +1073,7 @@ class EditorComments extends BaseEditorOption<EditorOption.comments, EditorComme
}
public validate(_input: any): EditorCommentsOptions {
if (typeof _input !== 'object') {
if (!_input || typeof _input !== 'object') {
return this.defaultValue;
}
const input = _input as IEditorCommentsOptions;
@@ -1259,6 +1259,10 @@ export interface IEditorFindOptions {
* Controls if the Find Widget should read or modify the shared find clipboard on macOS
*/
globalFindClipboard?: boolean;
/**
* Controls whether the search automatically restarts from the beginning (or the end) when no further matches can be found
*/
loop?: boolean;
}
export type EditorFindOptions = Readonly<Required<IEditorFindOptions>>;
@@ -1270,7 +1274,8 @@ class EditorFind extends BaseEditorOption<EditorOption.find, EditorFindOptions>
seedSearchStringFromSelection: true,
autoFindInSelection: 'never',
globalFindClipboard: false,
addExtraSpaceOnTop: true
addExtraSpaceOnTop: true,
loop: true
};
super(
EditorOption.find, 'find', defaults,
@@ -1301,13 +1306,19 @@ class EditorFind extends BaseEditorOption<EditorOption.find, EditorFindOptions>
type: 'boolean',
default: defaults.addExtraSpaceOnTop,
description: nls.localize('find.addExtraSpaceOnTop', "Controls whether the Find Widget should add extra lines on top of the editor. When true, you can scroll beyond the first line when the Find Widget is visible.")
}
},
'editor.find.loop': {
type: 'boolean',
default: defaults.loop,
description: nls.localize('find.loop', "Controls whether the search automatically restarts from the beginning (or the end) when no further matches can be found.")
},
}
);
}
public validate(_input: any): EditorFindOptions {
if (typeof _input !== 'object') {
if (!_input || typeof _input !== 'object') {
return this.defaultValue;
}
const input = _input as IEditorFindOptions;
@@ -1317,7 +1328,8 @@ class EditorFind extends BaseEditorOption<EditorOption.find, EditorFindOptions>
? (_input.autoFindInSelection ? 'always' : 'never')
: EditorStringEnumOption.stringSet<'never' | 'always' | 'multiline'>(input.autoFindInSelection, this.defaultValue.autoFindInSelection, ['never', 'always', 'multiline']),
globalFindClipboard: EditorBooleanOption.boolean(input.globalFindClipboard, this.defaultValue.globalFindClipboard),
addExtraSpaceOnTop: EditorBooleanOption.boolean(input.addExtraSpaceOnTop, this.defaultValue.addExtraSpaceOnTop)
addExtraSpaceOnTop: EditorBooleanOption.boolean(input.addExtraSpaceOnTop, this.defaultValue.addExtraSpaceOnTop),
loop: EditorBooleanOption.boolean(input.loop, this.defaultValue.loop),
};
}
}
@@ -1532,7 +1544,7 @@ class EditorGoToLocation extends BaseEditorOption<EditorOption.gotoLocation, GoT
}
public validate(_input: any): GoToLocationOptions {
if (typeof _input !== 'object') {
if (!_input || typeof _input !== 'object') {
return this.defaultValue;
}
const input = _input as IGotoLocationOptions;
@@ -1610,7 +1622,7 @@ class EditorHover extends BaseEditorOption<EditorOption.hover, EditorHoverOption
}
public validate(_input: any): EditorHoverOptions {
if (typeof _input !== 'object') {
if (!_input || typeof _input !== 'object') {
return this.defaultValue;
}
const input = _input as IEditorHoverOptions;
@@ -2036,7 +2048,7 @@ class EditorLightbulb extends BaseEditorOption<EditorOption.lightbulb, EditorLig
}
public validate(_input: any): EditorLightbulbOptions {
if (typeof _input !== 'object') {
if (!_input || typeof _input !== 'object') {
return this.defaultValue;
}
const input = _input as IEditorLightbulbOptions;
@@ -2180,7 +2192,7 @@ class EditorMinimap extends BaseEditorOption<EditorOption.minimap, EditorMinimap
}
public validate(_input: any): EditorMinimapOptions {
if (typeof _input !== 'object') {
if (!_input || typeof _input !== 'object') {
return this.defaultValue;
}
const input = _input as IEditorMinimapOptions;
@@ -2255,7 +2267,7 @@ class EditorPadding extends BaseEditorOption<EditorOption.padding, InternalEdito
}
public validate(_input: any): InternalEditorPaddingOptions {
if (typeof _input !== 'object') {
if (!_input || typeof _input !== 'object') {
return this.defaultValue;
}
const input = _input as IEditorPaddingOptions;
@@ -2313,7 +2325,7 @@ class EditorParameterHints extends BaseEditorOption<EditorOption.parameterHints,
}
public validate(_input: any): InternalParameterHintOptions {
if (typeof _input !== 'object') {
if (!_input || typeof _input !== 'object') {
return this.defaultValue;
}
const input = _input as IEditorParameterHintOptions;
@@ -2403,7 +2415,7 @@ class EditorQuickSuggestions extends BaseEditorOption<EditorOption.quickSuggesti
if (typeof _input === 'boolean') {
return _input;
}
if (typeof _input === 'object') {
if (_input && typeof _input === 'object') {
const input = _input as IQuickSuggestionsOptions;
const opts = {
other: EditorBooleanOption.boolean(input.other, this.defaultValue.other),
@@ -2553,7 +2565,7 @@ class EditorRulers extends BaseEditorOption<EditorOption.rulers, IRulerOption[]>
column: EditorIntOption.clampedInt(_element, 0, 0, 10000),
color: null
});
} else if (typeof _element === 'object') {
} else if (_element && typeof _element === 'object') {
const element = _element as IRulerOption;
rulers.push({
column: EditorIntOption.clampedInt(element.column, 0, 0, 10000),
@@ -2687,7 +2699,7 @@ class EditorScrollbar extends BaseEditorOption<EditorOption.scrollbar, InternalE
}
public validate(_input: any): InternalEditorScrollbarOptions {
if (typeof _input !== 'object') {
if (!_input || typeof _input !== 'object') {
return this.defaultValue;
}
const input = _input as IEditorScrollbarOptions;
@@ -3108,7 +3120,7 @@ class EditorSuggest extends BaseEditorOption<EditorOption.suggest, InternalSugge
}
public validate(_input: any): InternalSuggestOptions {
if (typeof _input !== 'object') {
if (!_input || typeof _input !== 'object') {
return this.defaultValue;
}
const input = _input as ISuggestOptions;

View File

@@ -10,6 +10,7 @@ export namespace EditorContextKeys {
export const editorSimpleInput = new RawContextKey<boolean>('editorSimpleInput', false);
/**
* A context key that is set when the editor's text has focus (cursor is blinking).
* Is false when focus is in simple editor widgets (repl input, scm commit input).
*/
export const editorTextFocus = new RawContextKey<boolean>('editorTextFocus', false);
/**

View File

@@ -56,77 +56,80 @@ export function ensureValidWordDefinition(wordDefinition?: RegExp | null): RegEx
return result;
}
function getWordAtPosFast(column: number, wordDefinition: RegExp, text: string, textOffset: number): IWordAtPosition | null {
// find whitespace enclosed text around column and match from there
const _defaultConfig = {
maxLen: 1000,
windowSize: 15,
timeBudget: 150
};
let pos = column - 1 - textOffset;
let start = text.lastIndexOf(' ', pos - 1) + 1;
export function getWordAtText(column: number, wordDefinition: RegExp, text: string, textOffset: number, config = _defaultConfig): IWordAtPosition | null {
wordDefinition.lastIndex = start;
if (text.length > config.maxLen) {
// don't throw strings that long at the regexp
// but use a sub-string in which a word must occur
let start = column - config.maxLen / 2;
if (start < 0) {
textOffset += column;
start = 0;
} else {
textOffset += start;
}
text = text.substring(start, column + config.maxLen / 2);
return getWordAtText(column, wordDefinition, text, textOffset, config);
}
const t1 = Date.now();
const pos = column - 1 - textOffset;
let prevRegexIndex = -1;
let match: RegExpMatchArray | null = null;
for (let i = 1; ; i++) {
// check time budget
if (Date.now() - t1 >= config.timeBudget) {
// break;
}
// reset the index at which the regexp should start matching, also know where it
// should stop so that subsequent search don't repeat previous searches
const regexIndex = pos - config.windowSize * i;
wordDefinition.lastIndex = Math.max(0, regexIndex);
match = _findRegexMatchEnclosingPosition(wordDefinition, text, pos, prevRegexIndex);
// stop: found something
if (match) {
break;
}
// stop: searched at start
if (regexIndex <= 0) {
break;
}
prevRegexIndex = regexIndex;
}
if (match) {
let result = {
word: match[0],
startColumn: textOffset + 1 + match.index!,
endColumn: textOffset + 1 + wordDefinition.lastIndex
};
wordDefinition.lastIndex = 0;
return result;
}
return null;
}
function _findRegexMatchEnclosingPosition(wordDefinition: RegExp, text: string, pos: number, stopPos: number): RegExpMatchArray | null {
let match: RegExpMatchArray | null;
while (match = wordDefinition.exec(text)) {
const matchIndex = match.index || 0;
if (matchIndex <= pos && wordDefinition.lastIndex >= pos) {
return {
word: match[0],
startColumn: textOffset + 1 + matchIndex,
endColumn: textOffset + 1 + wordDefinition.lastIndex
};
}
}
return null;
}
function getWordAtPosSlow(column: number, wordDefinition: RegExp, text: string, textOffset: number): IWordAtPosition | null {
// matches all words starting at the beginning
// of the input until it finds a match that encloses
// the desired column. slow but correct
let pos = column - 1 - textOffset;
wordDefinition.lastIndex = 0;
let match: RegExpMatchArray | null;
while (match = wordDefinition.exec(text)) {
const matchIndex = match.index || 0;
if (matchIndex > pos) {
// |nW -> matched only after the pos
return match;
} else if (stopPos > 0 && matchIndex > stopPos) {
return null;
} else if (wordDefinition.lastIndex >= pos) {
// W|W -> match encloses pos
return {
word: match[0],
startColumn: textOffset + 1 + matchIndex,
endColumn: textOffset + 1 + wordDefinition.lastIndex
};
}
}
return null;
}
export function getWordAtText(column: number, wordDefinition: RegExp, text: string, textOffset: number): IWordAtPosition | null {
// if `words` can contain whitespace character we have to use the slow variant
// otherwise we use the fast variant of finding a word
wordDefinition.lastIndex = 0;
let match = wordDefinition.exec(text);
if (!match) {
return null;
}
// todo@joh the `match` could already be the (first) word
const ret = match[0].indexOf(' ') >= 0
// did match a word which contains a space character -> use slow word find
? getWordAtPosSlow(column, wordDefinition, text, textOffset)
// sane word definition -> use fast word find
: getWordAtPosFast(column, wordDefinition, text, textOffset);
// both (getWordAtPosFast and getWordAtPosSlow) leave the wordDefinition-RegExp
// in an undefined state and to not confuse other users of the wordDefinition
// we reset the lastIndex
wordDefinition.lastIndex = 0;
return ret;
}

View File

@@ -19,6 +19,7 @@ import { LanguageFeatureRegistry } from 'vs/editor/common/modes/languageFeatureR
import { TokenizationRegistryImpl } from 'vs/editor/common/modes/tokenizationRegistry';
import { ExtensionIdentifier } from 'vs/platform/extensions/common/extensions';
import { IMarkerData } from 'vs/platform/markers/common/markers';
import { iconRegistry, Codicon } from 'vs/base/common/codicons';
/**
* Open ended enum at runtime
@@ -359,7 +360,13 @@ export const completionKindToCssClass = (function () {
data[CompletionItemKind.Issue] = 'issues';
return function (kind: CompletionItemKind) {
return data[kind] || 'property';
const name = data[kind];
let codicon = name && iconRegistry.get(name);
if (!codicon) {
console.info('No codicon found for CompletionItemKind ' + kind);
codicon = Codicon.symbolProperty;
}
return codicon.classNames;
};
})();
@@ -697,6 +704,12 @@ export interface SignatureInformation {
* The parameters of this signature.
*/
parameters: ParameterInformation[];
/**
* Index of the active parameter.
*
* If provided, this is used in place of `SignatureHelp.activeSignature`.
*/
activeParameter?: number;
}
/**
* Signature help represents the signature of something
@@ -1037,7 +1050,13 @@ export namespace SymbolKinds {
* @internal
*/
export function toCssClassName(kind: SymbolKind, inline?: boolean): string {
return `codicon ${inline ? 'inline' : 'block'} codicon-symbol-${byKind.get(kind) || 'property'}`;
const symbolName = byKind.get(kind);
let codicon = symbolName && iconRegistry.get('symbol-' + symbolName);
if (!codicon) {
console.info('No codicon found for SymbolKind ' + kind);
codicon = Codicon.symbolProperty;
}
return `${inline ? 'inline' : 'block'} ${codicon.classNames}`;
}
}
@@ -1393,7 +1412,10 @@ export interface RenameProvider {
export interface AuthenticationSession {
id: string;
getAccessToken(): Thenable<string>;
accountName: string;
account: {
displayName: string;
id: string;
}
}
/**

View File

@@ -114,7 +114,7 @@ class EditorScrollable extends Disposable {
scrollWidth: dimensions.scrollWidth,
height: dimensions.height,
scrollHeight: dimensions.scrollHeight
});
}, true);
const contentWidthChanged = (oldDimensions.contentWidth !== dimensions.contentWidth);
const contentHeightChanged = (oldDimensions.contentHeight !== dimensions.contentHeight);