Vscode merge (#4582)

* Merge from vscode 37cb23d3dd4f9433d56d4ba5ea3203580719a0bd

* fix issues with merges

* bump node version in azpipe

* replace license headers

* remove duplicate launch task

* fix build errors

* fix build errors

* fix tslint issues

* working through package and linux build issues

* more work

* wip

* fix packaged builds

* working through linux build errors

* wip

* wip

* wip

* fix mac and linux file limits

* iterate linux pipeline

* disable editor typing

* revert series to parallel

* remove optimize vscode from linux

* fix linting issues

* revert testing change

* add work round for new node

* readd packaging for extensions

* fix issue with angular not resolving decorator dependencies
This commit is contained in:
Anthony Dresser
2019-03-19 17:44:35 -07:00
committed by GitHub
parent 833d197412
commit 87765e8673
1879 changed files with 54505 additions and 38058 deletions

View File

@@ -98,9 +98,9 @@ export class ReplaceCommandWithOffsetCursorState implements ICommand {
export class ReplaceCommandThatPreservesSelection implements ICommand {
private _range: Range;
private _text: string;
private _initialSelection: Selection;
private readonly _range: Range;
private readonly _text: string;
private readonly _initialSelection: Selection;
private _selectionId: string;
constructor(editRange: Range, text: string, initialSelection: Selection) {

View File

@@ -15,34 +15,61 @@ import { LanguageConfigurationRegistry } from 'vs/editor/common/modes/languageCo
export interface IShiftCommandOpts {
isUnshift: boolean;
tabSize: number;
oneIndent: string;
indentSize: number;
insertSpaces: boolean;
useTabStops: boolean;
}
const repeatCache: { [str: string]: string[]; } = Object.create(null);
export function cachedStringRepeat(str: string, count: number): string {
if (!repeatCache[str]) {
repeatCache[str] = ['', str];
}
const cache = repeatCache[str];
for (let i = cache.length; i <= count; i++) {
cache[i] = cache[i - 1] + str;
}
return cache[count];
}
export class ShiftCommand implements ICommand {
public static unshiftIndentCount(line: string, column: number, tabSize: number): number {
public static unshiftIndent(line: string, column: number, tabSize: number, indentSize: number, insertSpaces: boolean): string {
// Determine the visible column where the content starts
let contentStartVisibleColumn = CursorColumns.visibleColumnFromColumn(line, column, tabSize);
const contentStartVisibleColumn = CursorColumns.visibleColumnFromColumn(line, column, tabSize);
let desiredTabStop = CursorColumns.prevTabStop(contentStartVisibleColumn, tabSize);
// The `desiredTabStop` is a multiple of `tabSize` => determine the number of indents
return desiredTabStop / tabSize;
if (insertSpaces) {
const indent = cachedStringRepeat(' ', indentSize);
const desiredTabStop = CursorColumns.prevIndentTabStop(contentStartVisibleColumn, indentSize);
const indentCount = desiredTabStop / indentSize; // will be an integer
return cachedStringRepeat(indent, indentCount);
} else {
const indent = '\t';
const desiredTabStop = CursorColumns.prevRenderTabStop(contentStartVisibleColumn, tabSize);
const indentCount = desiredTabStop / tabSize; // will be an integer
return cachedStringRepeat(indent, indentCount);
}
}
public static shiftIndentCount(line: string, column: number, tabSize: number): number {
public static shiftIndent(line: string, column: number, tabSize: number, indentSize: number, insertSpaces: boolean): string {
// Determine the visible column where the content starts
let contentStartVisibleColumn = CursorColumns.visibleColumnFromColumn(line, column, tabSize);
const contentStartVisibleColumn = CursorColumns.visibleColumnFromColumn(line, column, tabSize);
let desiredTabStop = CursorColumns.nextTabStop(contentStartVisibleColumn, tabSize);
// The `desiredTabStop` is a multiple of `tabSize` => determine the number of indents
return desiredTabStop / tabSize;
if (insertSpaces) {
const indent = cachedStringRepeat(' ', indentSize);
const desiredTabStop = CursorColumns.nextIndentTabStop(contentStartVisibleColumn, indentSize);
const indentCount = desiredTabStop / indentSize; // will be an integer
return cachedStringRepeat(indent, indentCount);
} else {
const indent = '\t';
const desiredTabStop = CursorColumns.nextRenderTabStop(contentStartVisibleColumn, tabSize);
const indentCount = desiredTabStop / tabSize; // will be an integer
return cachedStringRepeat(indent, indentCount);
}
}
private _opts: IShiftCommandOpts;
private _selection: Selection;
private readonly _opts: IShiftCommandOpts;
private readonly _selection: Selection;
private _selectionId: string;
private _useLastEditRangeForCursorEndPosition: boolean;
private _selectionStartColumnStaysPut: boolean;
@@ -70,8 +97,7 @@ export class ShiftCommand implements ICommand {
endLine = endLine - 1;
}
const tabSize = this._opts.tabSize;
const oneIndent = this._opts.oneIndent;
const { tabSize, indentSize, insertSpaces } = this._opts;
const shouldIndentEmptyLines = (startLine === endLine);
// if indenting or outdenting on a whitespace only line
@@ -82,9 +108,6 @@ export class ShiftCommand implements ICommand {
}
if (this._opts.useTabStops) {
// indents[i] represents i * oneIndent
let indents: string[] = ['', oneIndent];
// keep track of previous line's "miss-alignment"
let previousLineExtraSpaces = 0, extraSpaces = 0;
for (let lineNumber = startLine; lineNumber <= endLine; lineNumber++ , previousLineExtraSpaces = extraSpaces) {
@@ -109,7 +132,7 @@ export class ShiftCommand implements ICommand {
if (lineNumber > 1) {
let contentStartVisibleColumn = CursorColumns.visibleColumnFromColumn(lineText, indentationEndIndex + 1, tabSize);
if (contentStartVisibleColumn % tabSize !== 0) {
if (contentStartVisibleColumn % indentSize !== 0) {
// The current line is "miss-aligned", so let's see if this is expected...
// This can only happen when it has trailing commas in the indent
if (model.isCheapToTokenize(lineNumber - 1)) {
@@ -117,7 +140,7 @@ export class ShiftCommand implements ICommand {
if (enterAction) {
extraSpaces = previousLineExtraSpaces;
if (enterAction.appendText) {
for (let j = 0, lenJ = enterAction.appendText.length; j < lenJ && extraSpaces < tabSize; j++) {
for (let j = 0, lenJ = enterAction.appendText.length; j < lenJ && extraSpaces < indentSize; j++) {
if (enterAction.appendText.charCodeAt(j) === CharCode.Space) {
extraSpaces++;
} else {
@@ -147,19 +170,14 @@ export class ShiftCommand implements ICommand {
continue;
}
let desiredIndentCount: number;
let desiredIndent: string;
if (this._opts.isUnshift) {
desiredIndentCount = ShiftCommand.unshiftIndentCount(lineText, indentationEndIndex + 1, tabSize);
desiredIndent = ShiftCommand.unshiftIndent(lineText, indentationEndIndex + 1, tabSize, indentSize, insertSpaces);
} else {
desiredIndentCount = ShiftCommand.shiftIndentCount(lineText, indentationEndIndex + 1, tabSize);
desiredIndent = ShiftCommand.shiftIndent(lineText, indentationEndIndex + 1, tabSize, indentSize, insertSpaces);
}
// Fill `indents`, as needed
for (let j = indents.length; j <= desiredIndentCount; j++) {
indents[j] = indents[j - 1] + oneIndent;
}
this._addEditOperation(builder, new Range(lineNumber, 1, lineNumber, indentationEndIndex + 1), indents[desiredIndentCount]);
this._addEditOperation(builder, new Range(lineNumber, 1, lineNumber, indentationEndIndex + 1), desiredIndent);
if (lineNumber === startLine) {
// Force the startColumn to stay put because we're inserting after it
this._selectionStartColumnStaysPut = (this._selection.startColumn <= indentationEndIndex + 1);
@@ -167,6 +185,8 @@ export class ShiftCommand implements ICommand {
}
} else {
const oneIndent = (insertSpaces ? cachedStringRepeat(' ', indentSize) : '\t');
for (let lineNumber = startLine; lineNumber <= endLine; lineNumber++) {
const lineText = model.getLineContent(lineNumber);
let indentationEndIndex = strings.firstNonWhitespaceIndex(lineText);
@@ -193,7 +213,7 @@ export class ShiftCommand implements ICommand {
if (this._opts.isUnshift) {
indentationEndIndex = Math.min(indentationEndIndex, tabSize);
indentationEndIndex = Math.min(indentationEndIndex, indentSize);
for (let i = 0; i < indentationEndIndex; i++) {
const chr = lineText.charCodeAt(i);
if (chr === CharCode.Tab) {

View File

@@ -9,9 +9,9 @@ import { ICommand, ICursorStateComputerData, IEditOperationBuilder } from 'vs/ed
import { ITextModel } from 'vs/editor/common/model';
export class SurroundSelectionCommand implements ICommand {
private _range: Selection;
private _charBeforeSelection: string;
private _charAfterSelection: string;
private readonly _range: Selection;
private readonly _charBeforeSelection: string;
private readonly _charAfterSelection: string;
constructor(range: Selection, charBeforeSelection: string, charAfterSelection: string) {
this._range = range;

View File

@@ -13,9 +13,9 @@ import { IIdentifiedSingleEditOperation, ITextModel } from 'vs/editor/common/mod
export class TrimTrailingWhitespaceCommand implements ICommand {
private selection: Selection;
private readonly selection: Selection;
private selectionId: string;
private cursors: Position[];
private readonly cursors: Position[];
constructor(selection: Selection, cursors: Position[]) {
this.selection = selection;

View File

@@ -17,6 +17,7 @@ import { Registry } from 'vs/platform/registry/common/platform';
import EDITOR_DEFAULTS = editorOptions.EDITOR_DEFAULTS;
import EDITOR_FONT_DEFAULTS = editorOptions.EDITOR_FONT_DEFAULTS;
import EDITOR_MODEL_DEFAULTS = editorOptions.EDITOR_MODEL_DEFAULTS;
import { AccessibilitySupport } from 'vs/platform/accessibility/common/accessibility';
/**
* Control what pressing Tab does.
@@ -57,7 +58,7 @@ export interface IEnvConfiguration {
emptySelectionClipboard: boolean;
pixelRatio: number;
zoomLevel: number;
accessibilitySupport: platform.AccessibilitySupport;
accessibilitySupport: AccessibilitySupport;
}
const hasOwnProperty = Object.hasOwnProperty;
@@ -264,6 +265,11 @@ const editorConfiguration: IConfigurationNode = {
'default': 'on',
'description': nls.localize('lineNumbers', "Controls the display of line numbers.")
},
'editor.renderFinalNewline': {
'type': 'boolean',
'default': EDITOR_DEFAULTS.viewInfo.renderFinalNewline,
'description': nls.localize('renderFinalNewline', "Render last line number when the file ends with a newline.")
},
'editor.rulers': {
'type': 'array',
'items': {
@@ -283,6 +289,20 @@ const editorConfiguration: IConfigurationNode = {
'minimum': 1,
'markdownDescription': nls.localize('tabSize', "The number of spaces a tab is equal to. This setting is overridden based on the file contents when `#editor.detectIndentation#` is on.")
},
// 'editor.indentSize': {
// 'anyOf': [
// {
// 'type': 'string',
// 'enum': ['tabSize']
// },
// {
// 'type': 'number',
// 'minimum': 1
// }
// ],
// 'default': 'tabSize',
// 'markdownDescription': nls.localize('indentSize', "The number of spaces used for indentation or 'tabSize' to use the value from `#editor.tabSize#`. This setting is overridden based on the file contents when `#editor.detectIndentation#` is on.")
// },
'editor.insertSpaces': {
'type': 'boolean',
'default': EDITOR_MODEL_DEFAULTS.insertSpaces,
@@ -371,6 +391,11 @@ const editorConfiguration: IConfigurationNode = {
'description': nls.localize('find.globalFindClipboard', "Controls whether the Find Widget should read or modify the shared find clipboard on macOS."),
'included': platform.isMacintosh
},
'editor.find.addExtraSpaceOnTop': {
'type': 'boolean',
'default': true,
'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.wordWrap': {
'type': 'string',
'enum': ['off', 'on', 'wordWrapColumn', 'bounded'],
@@ -654,6 +679,166 @@ const editorConfiguration: IConfigurationNode = {
default: true,
description: nls.localize('suggest.snippetsPreventQuickSuggestions', "Control whether an active snippet prevents quick suggestions.")
},
'editor.suggest.showIcons': {
type: 'boolean',
default: EDITOR_DEFAULTS.contribInfo.suggest.showIcons,
description: nls.localize('suggest.showIcons', "Controls whether to show or hide icons in suggestions.")
},
'editor.suggest.maxVisibleSuggestions': {
type: 'number',
default: EDITOR_DEFAULTS.contribInfo.suggest.maxVisibleSuggestions,
minimum: 1,
maximum: 12,
description: nls.localize('suggest.maxVisibleSuggestions', "Controls how many suggestions IntelliSense will show before showing a scrollbar.")
},
'editor.suggest.filteredTypes': {
type: 'object',
default: { keyword: true },
markdownDescription: nls.localize('suggest.filtered', "Controls whether some suggestion types should be filtered from IntelliSense. A list of suggestion types can be found here: https://code.visualstudio.com/docs/editor/intellisense#_types-of-completions."),
properties: {
method: {
type: 'boolean',
default: true,
markdownDescription: nls.localize('suggest.filtered.method', "When set to `false` IntelliSense never shows `method` suggestions.")
},
function: {
type: 'boolean',
default: true,
markdownDescription: nls.localize('suggest.filtered.function', "When set to `false` IntelliSense never shows `function` suggestions.")
},
constructor: {
type: 'boolean',
default: true,
markdownDescription: nls.localize('suggest.filtered.constructor', "When set to `false` IntelliSense never shows `constructor` suggestions.")
},
field: {
type: 'boolean',
default: true,
markdownDescription: nls.localize('suggest.filtered.field', "When set to `false` IntelliSense never shows `field` suggestions.")
},
variable: {
type: 'boolean',
default: true,
markdownDescription: nls.localize('suggest.filtered.variable', "When set to `false` IntelliSense never shows `variable` suggestions.")
},
class: {
type: 'boolean',
default: true,
markdownDescription: nls.localize('suggest.filtered.class', "When set to `false` IntelliSense never shows `class` suggestions.")
},
struct: {
type: 'boolean',
default: true,
markdownDescription: nls.localize('suggest.filtered.struct', "When set to `false` IntelliSense never shows `struct` suggestions.")
},
interface: {
type: 'boolean',
default: true,
markdownDescription: nls.localize('suggest.filtered.interface', "When set to `false` IntelliSense never shows `interface` suggestions.")
},
module: {
type: 'boolean',
default: true,
markdownDescription: nls.localize('suggest.filtered.module', "When set to `false` IntelliSense never shows `module` suggestions.")
},
property: {
type: 'boolean',
default: true,
markdownDescription: nls.localize('suggest.filtered.property', "When set to `false` IntelliSense never shows `property` suggestions.")
},
event: {
type: 'boolean',
default: true,
markdownDescription: nls.localize('suggest.filtered.event', "When set to `false` IntelliSense never shows `event` suggestions.")
},
operator: {
type: 'boolean',
default: true,
markdownDescription: nls.localize('suggest.filtered.operator', "When set to `false` IntelliSense never shows `operator` suggestions.")
},
unit: {
type: 'boolean',
default: true,
markdownDescription: nls.localize('suggest.filtered.unit', "When set to `false` IntelliSense never shows `unit` suggestions.")
},
value: {
type: 'boolean',
default: true,
markdownDescription: nls.localize('suggest.filtered.value', "When set to `false` IntelliSense never shows `value` suggestions.")
},
constant: {
type: 'boolean',
default: true,
markdownDescription: nls.localize('suggest.filtered.constant', "When set to `false` IntelliSense never shows `constant` suggestions.")
},
enum: {
type: 'boolean',
default: true,
markdownDescription: nls.localize('suggest.filtered.enum', "When set to `false` IntelliSense never shows `enum` suggestions.")
},
enumMember: {
type: 'boolean',
default: true,
markdownDescription: nls.localize('suggest.filtered.enumMember', "When set to `false` IntelliSense never shows `enumMember` suggestions.")
},
keyword: {
type: 'boolean',
default: true,
markdownDescription: nls.localize('suggest.filtered.keyword', "When set to `false` IntelliSense never shows `keyword` suggestions.")
},
text: {
type: 'boolean',
default: true,
markdownDescription: nls.localize('suggest.filtered.text', "When set to `false` IntelliSense never shows `text` suggestions.")
},
color: {
type: 'boolean',
default: true,
markdownDescription: nls.localize('suggest.filtered.color', "When set to `false` IntelliSense never shows `color` suggestions.")
},
file: {
type: 'boolean',
default: true,
markdownDescription: nls.localize('suggest.filtered.file', "When set to `false` IntelliSense never shows `file` suggestions.")
},
reference: {
type: 'boolean',
default: true,
markdownDescription: nls.localize('suggest.filtered.reference', "When set to `false` IntelliSense never shows `reference` suggestions.")
},
customcolor: {
type: 'boolean',
default: true,
markdownDescription: nls.localize('suggest.filtered.customcolor', "When set to `false` IntelliSense never shows `customcolor` suggestions.")
},
folder: {
type: 'boolean',
default: true,
markdownDescription: nls.localize('suggest.filtered.folder', "When set to `false` IntelliSense never shows `folder` suggestions.")
},
typeParameter: {
type: 'boolean',
default: true,
markdownDescription: nls.localize('suggest.filtered.typeParameter', "When set to `false` IntelliSense never shows `typeParameter` suggestions.")
},
snippet: {
type: 'boolean',
default: true,
markdownDescription: nls.localize('suggest.filtered.snippet', "When set to `false` IntelliSense never shows `snippet` suggestions.")
},
}
},
'editor.gotoLocation.many': {
description: nls.localize('editor.gotoLocation.many', "Controls the behaviour of 'go to'-commands, like go to definition, when multiple target locations exist."),
type: 'string',
enum: ['peek', 'revealAndPeek', 'reveal'],
default: 'peek',
enumDescriptions: [
nls.localize('editor.gotoLocation.many.peek', 'Show peek view of the results at the request location'),
nls.localize('editor.gotoLocation.many.revealAndPeek', 'Reveal the first result and show peek view at its location'),
nls.localize('editor.gotoLocation.many.reveal', 'Reveal the first result and ignore others')
]
},
'editor.selectionHighlight': {
'type': 'boolean',
'default': EDITOR_DEFAULTS.contribInfo.selectionHighlight,
@@ -832,6 +1017,11 @@ const editorConfiguration: IConfigurationNode = {
'default': EDITOR_DEFAULTS.contribInfo.lightbulbEnabled,
'description': nls.localize('codeActions', "Enables the code action lightbulb in the editor.")
},
'editor.maxTokenizationLineLength': {
'type': 'integer',
'default': 20_000,
'description': nls.localize('maxTokenizationLineLength', "Lines above this length will not be tokenized for performance reasons")
},
'editor.codeActionsOnSave': {
'type': 'object',
'properties': {

View File

@@ -11,6 +11,8 @@ import { ScrollbarVisibility } from 'vs/base/common/scrollable';
import { FontInfo } from 'vs/editor/common/config/fontInfo';
import { Constants } from 'vs/editor/common/core/uint';
import { USUAL_WORD_SEPARATORS } from 'vs/editor/common/model/wordHelper';
import { AccessibilitySupport } from 'vs/platform/accessibility/common/accessibility';
import { isObject } from 'vs/base/common/types';
/**
* Configuration options for editor scrollbars
@@ -85,6 +87,10 @@ export interface IEditorFindOptions {
* Controls if Find in Selection flag is turned on when multiple lines of text are selected in the editor.
*/
autoFindInSelection: boolean;
/*
* Controls whether the Find Widget should add extra lines on top of the editor.
*/
addExtraSpaceOnTop?: boolean;
/**
* @internal
* Controls if the Find Widget should read or modify the shared find clipboard on macOS
@@ -194,11 +200,29 @@ export interface ISuggestOptions {
* Favours words that appear close to the cursor.
*/
localityBonus?: boolean;
/**
* Enable using global storage for remembering suggestions.
*/
shareSuggestSelections?: boolean;
/**
* Enable or disable icons in suggestions. Defaults to true.
*/
showIcons?: boolean;
/**
* Max suggestions to show in suggestions. Defaults to 12.
*/
maxVisibleSuggestions?: boolean;
/**
* Names of suggestion types to filter.
*/
filteredTypes?: Record<string, boolean>;
}
export interface IGotoLocationOptions {
/**
* Control how goto-command work when having multiple results.
*/
many?: 'peek' | 'revealAndPeek' | 'reveal';
}
/**
@@ -244,6 +268,11 @@ export interface IEditorOptions {
* Defaults to true.
*/
lineNumbers?: 'on' | 'off' | 'relative' | 'interval' | ((lineNumber: number) => string);
/**
* Render last line number when the file ends with a newline.
* Defaults to true on Windows/Mac and to false on Linux.
*/
renderFinalNewline?: boolean;
/**
* Should the corresponding line be selected when clicking on the line number?
* Defaults to true.
@@ -482,6 +511,10 @@ export interface IEditorOptions {
* Suggest options.
*/
suggest?: ISuggestOptions;
/**
*
*/
gotoLocation?: IGotoLocationOptions;
/**
* Enable quick suggestions (shadow suggestions)
* Defaults to true.
@@ -496,11 +529,6 @@ export interface IEditorOptions {
* Parameter hint options.
*/
parameterHints?: IEditorParameterHintOptions;
/**
* Render icons in suggestions box.
* Defaults to true.
*/
iconsInSuggestions?: boolean;
/**
* Options for auto closing brackets.
* Defaults to language defined behavior.
@@ -894,6 +922,7 @@ export interface InternalEditorMinimapOptions {
export interface InternalEditorFindOptions {
readonly seedSearchStringFromSelection: boolean;
readonly autoFindInSelection: boolean;
readonly addExtraSpaceOnTop: boolean;
/**
* @internal
*/
@@ -906,12 +935,19 @@ export interface InternalEditorHoverOptions {
readonly sticky: boolean;
}
export interface InternalGoToLocationOptions {
readonly many: 'peek' | 'revealAndPeek' | 'reveal';
}
export interface InternalSuggestOptions {
readonly filterGraceful: boolean;
readonly snippets: 'top' | 'bottom' | 'inline' | 'none';
readonly snippetsPreventQuickSuggestions: boolean;
readonly localityBonus: boolean;
readonly shareSuggestSelections: boolean;
readonly showIcons: boolean;
readonly maxVisibleSuggestions: number;
readonly filteredTypes: Record<string, boolean>;
}
export interface InternalParameterHintOptions {
@@ -946,6 +982,7 @@ export interface InternalEditorViewOptions {
readonly ariaLabel: string;
readonly renderLineNumbers: RenderLineNumbersType;
readonly renderCustomLineNumbers: ((lineNumber: number) => string) | null;
readonly renderFinalNewline: boolean;
readonly selectOnLineNumbers: boolean;
readonly glyphMargin: boolean;
readonly revealHorizontalRightPadding: number;
@@ -981,7 +1018,6 @@ export interface EditorContribOptions {
readonly quickSuggestions: boolean | { other: boolean, comments: boolean, strings: boolean };
readonly quickSuggestionsDelay: number;
readonly parameterHints: InternalParameterHintOptions;
readonly iconsInSuggestions: boolean;
readonly formatOnType: boolean;
readonly formatOnPaste: boolean;
readonly suggestOnTriggerCharacters: boolean;
@@ -993,6 +1029,7 @@ export interface EditorContribOptions {
readonly suggestLineHeight: number;
readonly tabCompletion: 'on' | 'off' | 'onlySnippets';
readonly suggest: InternalSuggestOptions;
readonly gotoLocation: InternalGoToLocationOptions;
readonly selectionHighlight: boolean;
readonly occurrencesHighlight: boolean;
readonly codeLens: boolean;
@@ -1059,7 +1096,7 @@ export class InternalEditorOptions {
/**
* @internal
*/
readonly accessibilitySupport: platform.AccessibilitySupport;
readonly accessibilitySupport: AccessibilitySupport;
readonly multiCursorModifier: 'altKey' | 'ctrlKey' | 'metaKey';
readonly multiCursorMergeOverlapping: boolean;
readonly showUnused: boolean;
@@ -1092,7 +1129,7 @@ export class InternalEditorOptions {
editorClassName: string;
lineHeight: number;
readOnly: boolean;
accessibilitySupport: platform.AccessibilitySupport;
accessibilitySupport: AccessibilitySupport;
multiCursorModifier: 'altKey' | 'ctrlKey' | 'metaKey';
multiCursorMergeOverlapping: boolean;
wordSeparators: string;
@@ -1253,6 +1290,7 @@ export class InternalEditorOptions {
&& a.ariaLabel === b.ariaLabel
&& a.renderLineNumbers === b.renderLineNumbers
&& a.renderCustomLineNumbers === b.renderCustomLineNumbers
&& a.renderFinalNewline === b.renderFinalNewline
&& a.selectOnLineNumbers === b.selectOnLineNumbers
&& a.glyphMargin === b.glyphMargin
&& a.revealHorizontalRightPadding === b.revealHorizontalRightPadding
@@ -1323,6 +1361,7 @@ export class InternalEditorOptions {
a.seedSearchStringFromSelection === b.seedSearchStringFromSelection
&& a.autoFindInSelection === b.autoFindInSelection
&& a.globalFindClipboard === b.globalFindClipboard
&& a.addExtraSpaceOnTop === b.addExtraSpaceOnTop
);
}
@@ -1360,7 +1399,19 @@ export class InternalEditorOptions {
&& a.snippets === b.snippets
&& a.snippetsPreventQuickSuggestions === b.snippetsPreventQuickSuggestions
&& a.localityBonus === b.localityBonus
&& a.shareSuggestSelections === b.shareSuggestSelections;
&& a.shareSuggestSelections === b.shareSuggestSelections
&& a.showIcons === b.showIcons
&& a.maxVisibleSuggestions === b.maxVisibleSuggestions;
}
}
private static _equalsGotoLocationOptions(a: InternalGoToLocationOptions | undefined, b: InternalGoToLocationOptions | undefined): boolean {
if (a === b) {
return true;
} else if (!a || !b) {
return false;
} else {
return a.many === b.many;
}
}
@@ -1393,7 +1444,6 @@ export class InternalEditorOptions {
&& InternalEditorOptions._equalsQuickSuggestions(a.quickSuggestions, b.quickSuggestions)
&& a.quickSuggestionsDelay === b.quickSuggestionsDelay
&& this._equalsParameterHintOptions(a.parameterHints, b.parameterHints)
&& a.iconsInSuggestions === b.iconsInSuggestions
&& a.formatOnType === b.formatOnType
&& a.formatOnPaste === b.formatOnPaste
&& a.suggestOnTriggerCharacters === b.suggestOnTriggerCharacters
@@ -1405,6 +1455,7 @@ export class InternalEditorOptions {
&& a.suggestLineHeight === b.suggestLineHeight
&& a.tabCompletion === b.tabCompletion
&& this._equalsSuggestOptions(a.suggest, b.suggest)
&& InternalEditorOptions._equalsGotoLocationOptions(a.gotoLocation, b.gotoLocation)
&& a.selectionHighlight === b.selectionHighlight
&& a.occurrencesHighlight === b.occurrencesHighlight
&& a.codeLens === b.codeLens
@@ -1602,7 +1653,7 @@ export interface IEnvironmentalOptions {
readonly emptySelectionClipboard: boolean;
readonly pixelRatio: number;
readonly tabFocusMode: boolean;
readonly accessibilitySupport: platform.AccessibilitySupport;
readonly accessibilitySupport: AccessibilitySupport;
}
function _boolean<T>(value: any, defaultValue: T): boolean | T {
@@ -1851,7 +1902,8 @@ export class EditorOptionsValidator {
return {
seedSearchStringFromSelection: _boolean(opts.seedSearchStringFromSelection, defaults.seedSearchStringFromSelection),
autoFindInSelection: _boolean(opts.autoFindInSelection, defaults.autoFindInSelection),
globalFindClipboard: _boolean(opts.globalFindClipboard, defaults.globalFindClipboard)
globalFindClipboard: _boolean(opts.globalFindClipboard, defaults.globalFindClipboard),
addExtraSpaceOnTop: _boolean(opts.addExtraSpaceOnTop, defaults.addExtraSpaceOnTop)
};
}
@@ -1892,7 +1944,17 @@ export class EditorOptionsValidator {
snippets: _stringSet<'top' | 'bottom' | 'inline' | 'none'>(opts.snippetSuggestions, defaults.snippets, ['top', 'bottom', 'inline', 'none']),
snippetsPreventQuickSuggestions: _boolean(suggestOpts.snippetsPreventQuickSuggestions, defaults.filterGraceful),
localityBonus: _boolean(suggestOpts.localityBonus, defaults.localityBonus),
shareSuggestSelections: _boolean(suggestOpts.shareSuggestSelections, defaults.shareSuggestSelections)
shareSuggestSelections: _boolean(suggestOpts.shareSuggestSelections, defaults.shareSuggestSelections),
showIcons: _boolean(suggestOpts.showIcons, defaults.showIcons),
maxVisibleSuggestions: _clampedInt(suggestOpts.maxVisibleSuggestions, defaults.maxVisibleSuggestions, 1, 12),
filteredTypes: isObject(suggestOpts.filteredTypes) ? suggestOpts.filteredTypes : Object.create(null)
};
}
private static _santizeGotoLocationOpts(opts: IEditorOptions, defaults: InternalGoToLocationOptions): InternalGoToLocationOptions {
const gotoOpts = opts.gotoLocation || {};
return {
many: _stringSet<'peek' | 'revealAndPeek' | 'reveal'>(gotoOpts.many, defaults.many, ['peek', 'revealAndPeek', 'reveal'])
};
}
@@ -1988,6 +2050,7 @@ export class EditorOptionsValidator {
ariaLabel: _string(opts.ariaLabel, defaults.ariaLabel),
renderLineNumbers: renderLineNumbers,
renderCustomLineNumbers: renderCustomLineNumbers,
renderFinalNewline: _boolean(opts.renderFinalNewline, defaults.renderFinalNewline),
selectOnLineNumbers: _boolean(opts.selectOnLineNumbers, defaults.selectOnLineNumbers),
glyphMargin: _boolean(opts.glyphMargin, defaults.glyphMargin),
revealHorizontalRightPadding: _clampedInt(opts.revealHorizontalRightPadding, defaults.revealHorizontalRightPadding, 0, 1000),
@@ -2036,7 +2099,6 @@ export class EditorOptionsValidator {
quickSuggestions: quickSuggestions,
quickSuggestionsDelay: _clampedInt(opts.quickSuggestionsDelay, defaults.quickSuggestionsDelay, Constants.MIN_SAFE_SMALL_INTEGER, Constants.MAX_SAFE_SMALL_INTEGER),
parameterHints: this._sanitizeParameterHintOpts(opts.parameterHints, defaults.parameterHints),
iconsInSuggestions: _boolean(opts.iconsInSuggestions, defaults.iconsInSuggestions),
formatOnType: _boolean(opts.formatOnType, defaults.formatOnType),
formatOnPaste: _boolean(opts.formatOnPaste, defaults.formatOnPaste),
suggestOnTriggerCharacters: _boolean(opts.suggestOnTriggerCharacters, defaults.suggestOnTriggerCharacters),
@@ -2048,6 +2110,7 @@ export class EditorOptionsValidator {
suggestLineHeight: _clampedInt(opts.suggestLineHeight, defaults.suggestLineHeight, 0, 1000),
tabCompletion: this._sanitizeTabCompletionOpts(opts.tabCompletion, defaults.tabCompletion),
suggest: this._sanitizeSuggestOpts(opts, defaults.suggest),
gotoLocation: this._santizeGotoLocationOpts(opts, defaults.gotoLocation),
selectionHighlight: _boolean(opts.selectionHighlight, defaults.selectionHighlight),
occurrencesHighlight: _boolean(opts.occurrencesHighlight, defaults.occurrencesHighlight),
codeLens: _boolean(opts.codeLens, defaults.codeLens),
@@ -2069,9 +2132,9 @@ export class EditorOptionsValidator {
*/
export class InternalEditorOptionsFactory {
private static _tweakValidatedOptions(opts: IValidatedEditorOptions, accessibilitySupport: platform.AccessibilitySupport): IValidatedEditorOptions {
const accessibilityIsOn = (accessibilitySupport === platform.AccessibilitySupport.Enabled);
const accessibilityIsOff = (accessibilitySupport === platform.AccessibilitySupport.Disabled);
private static _tweakValidatedOptions(opts: IValidatedEditorOptions, accessibilitySupport: AccessibilitySupport): IValidatedEditorOptions {
const accessibilityIsOn = (accessibilitySupport === AccessibilitySupport.Enabled);
const accessibilityIsOff = (accessibilitySupport === AccessibilitySupport.Disabled);
return {
inDiffEditor: opts.inDiffEditor,
wordSeparators: opts.wordSeparators,
@@ -2108,6 +2171,7 @@ export class InternalEditorOptionsFactory {
ariaLabel: (accessibilityIsOff ? nls.localize('accessibilityOffAriaLabel', "The editor is not accessible at this time. Press Alt+F1 for options.") : opts.viewInfo.ariaLabel),
renderLineNumbers: opts.viewInfo.renderLineNumbers,
renderCustomLineNumbers: opts.viewInfo.renderCustomLineNumbers,
renderFinalNewline: opts.viewInfo.renderFinalNewline,
selectOnLineNumbers: opts.viewInfo.selectOnLineNumbers,
glyphMargin: opts.viewInfo.glyphMargin,
revealHorizontalRightPadding: opts.viewInfo.revealHorizontalRightPadding,
@@ -2149,7 +2213,6 @@ export class InternalEditorOptionsFactory {
quickSuggestions: opts.contribInfo.quickSuggestions,
quickSuggestionsDelay: opts.contribInfo.quickSuggestionsDelay,
parameterHints: opts.contribInfo.parameterHints,
iconsInSuggestions: opts.contribInfo.iconsInSuggestions,
formatOnType: opts.contribInfo.formatOnType,
formatOnPaste: opts.contribInfo.formatOnPaste,
suggestOnTriggerCharacters: opts.contribInfo.suggestOnTriggerCharacters,
@@ -2161,6 +2224,7 @@ export class InternalEditorOptionsFactory {
suggestLineHeight: opts.contribInfo.suggestLineHeight,
tabCompletion: opts.contribInfo.tabCompletion,
suggest: opts.contribInfo.suggest,
gotoLocation: opts.contribInfo.gotoLocation,
selectionHighlight: (accessibilityIsOn ? false : opts.contribInfo.selectionHighlight), // DISABLED WHEN SCREEN READER IS ATTACHED
occurrencesHighlight: (accessibilityIsOn ? false : opts.contribInfo.occurrencesHighlight), // DISABLED WHEN SCREEN READER IS ATTACHED
codeLens: (accessibilityIsOn ? false : opts.contribInfo.codeLens), // DISABLED WHEN SCREEN READER IS ATTACHED
@@ -2179,14 +2243,14 @@ export class InternalEditorOptionsFactory {
public static createInternalEditorOptions(env: IEnvironmentalOptions, _opts: IValidatedEditorOptions) {
let accessibilitySupport: platform.AccessibilitySupport;
let accessibilitySupport: AccessibilitySupport;
if (_opts.accessibilitySupport === 'auto') {
// The editor reads the `accessibilitySupport` from the environment
accessibilitySupport = env.accessibilitySupport;
} else if (_opts.accessibilitySupport === 'on') {
accessibilitySupport = platform.AccessibilitySupport.Enabled;
accessibilitySupport = AccessibilitySupport.Enabled;
} else {
accessibilitySupport = platform.AccessibilitySupport.Disabled;
accessibilitySupport = AccessibilitySupport.Disabled;
}
// Disable some non critical features to get as best performance as possible
@@ -2232,7 +2296,7 @@ export class InternalEditorOptionsFactory {
const wordWrapColumn = opts.wordWrapColumn;
const wordWrapMinified = opts.wordWrapMinified;
if (accessibilitySupport === platform.AccessibilitySupport.Enabled) {
if (accessibilitySupport === AccessibilitySupport.Enabled) {
// See https://github.com/Microsoft/vscode/issues/27766
// Never enable wrapping when a screen reader is attached
// because arrow down etc. will not move the cursor in the way
@@ -2525,6 +2589,7 @@ export const EDITOR_FONT_DEFAULTS = {
*/
export const EDITOR_MODEL_DEFAULTS = {
tabSize: 4,
indentSize: 4,
insertSpaces: true,
detectIndentation: true,
trimAutoWhitespace: true,
@@ -2570,6 +2635,7 @@ export const EDITOR_DEFAULTS: IValidatedEditorOptions = {
ariaLabel: nls.localize('editorViewAccessibleLabel', "Editor content"),
renderLineNumbers: RenderLineNumbersType.On,
renderCustomLineNumbers: null,
renderFinalNewline: (platform.isLinux ? false : true),
selectOnLineNumbers: true,
glyphMargin: true,
revealHorizontalRightPadding: 30,
@@ -2633,7 +2699,6 @@ export const EDITOR_DEFAULTS: IValidatedEditorOptions = {
enabled: true,
cycle: false
},
iconsInSuggestions: true,
formatOnType: false,
formatOnPaste: false,
suggestOnTriggerCharacters: true,
@@ -2649,7 +2714,13 @@ export const EDITOR_DEFAULTS: IValidatedEditorOptions = {
snippets: 'inline',
snippetsPreventQuickSuggestions: true,
localityBonus: false,
shareSuggestSelections: false
shareSuggestSelections: false,
showIcons: true,
maxVisibleSuggestions: 12,
filteredTypes: Object.create(null)
},
gotoLocation: {
many: 'peek'
},
selectionHighlight: true,
occurrencesHighlight: true,
@@ -2661,7 +2732,8 @@ export const EDITOR_DEFAULTS: IValidatedEditorOptions = {
find: {
seedSearchStringFromSelection: true,
autoFindInSelection: false,
globalFindClipboard: false
globalFindClipboard: false,
addExtraSpaceOnTop: true
},
colorDecorators: true,
lightbulbEnabled: true,

View File

@@ -3,7 +3,6 @@
* Licensed under the Source EULA. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import * as nls from 'vs/nls';
import { onUnexpectedError } from 'vs/base/common/errors';
import { Emitter, Event } from 'vs/base/common/event';
import * as strings from 'vs/base/common/strings';
@@ -828,7 +827,8 @@ class CommandExecutor {
try {
command.getEditOperations(ctx.model, editOperationBuilder);
} catch (e) {
e.friendlyMessage = nls.localize('corrupt.commands', "Unexpected exception while executing command.");
// TODO@Alex use notification service if this should be user facing
// e.friendlyMessage = nls.localize('corrupt.commands', "Unexpected exception while executing command.");
onUnexpectedError(e);
return {
operations: [],

View File

@@ -74,8 +74,8 @@ export class CursorConfiguration {
public readonly readOnly: boolean;
public readonly tabSize: number;
public readonly indentSize: number;
public readonly insertSpaces: boolean;
public readonly oneIndent: string;
public readonly pageSize: number;
public readonly lineHeight: number;
public readonly useTabStops: boolean;
@@ -112,7 +112,6 @@ export class CursorConfiguration {
constructor(
languageIdentifier: LanguageIdentifier,
oneIndent: string,
modelOptions: TextModelResolvedOptions,
configuration: IConfiguration
) {
@@ -122,8 +121,8 @@ export class CursorConfiguration {
this.readOnly = c.readOnly;
this.tabSize = modelOptions.tabSize;
this.indentSize = modelOptions.indentSize;
this.insertSpaces = modelOptions.insertSpaces;
this.oneIndent = oneIndent;
this.pageSize = Math.max(1, Math.floor(c.layoutInfo.height / c.fontInfo.lineHeight) - 2);
this.lineHeight = c.lineHeight;
this.useTabStops = c.useTabStops;
@@ -176,7 +175,7 @@ export class CursorConfiguration {
}
public normalizeIndentation(str: string): string {
return TextModel.normalizeIndentation(str, this.tabSize, this.insertSpaces);
return TextModel.normalizeIndentation(str, this.indentSize, this.insertSpaces);
}
private static _getElectricCharacters(languageIdentifier: LanguageIdentifier): string[] | null {
@@ -342,7 +341,6 @@ export class CursorContext {
this.viewModel = viewModel;
this.config = new CursorConfiguration(
this.model.getLanguageIdentifier(),
this.model.getOneIndent(),
this.model.getOptions(),
configuration
);
@@ -518,7 +516,7 @@ export class CursorColumns {
for (let i = 0; i < endOffset; i++) {
let charCode = lineContent.charCodeAt(i);
if (charCode === CharCode.Tab) {
result = this.nextTabStop(result, tabSize);
result = this.nextRenderTabStop(result, tabSize);
} else if (strings.isFullWidthCharacter(charCode)) {
result = result + 2;
} else {
@@ -545,7 +543,7 @@ export class CursorColumns {
let afterVisibleColumn: number;
if (charCode === CharCode.Tab) {
afterVisibleColumn = this.nextTabStop(beforeVisibleColumn, tabSize);
afterVisibleColumn = this.nextRenderTabStop(beforeVisibleColumn, tabSize);
} else if (strings.isFullWidthCharacter(charCode)) {
afterVisibleColumn = beforeVisibleColumn + 2;
} else {
@@ -588,16 +586,30 @@ export class CursorColumns {
/**
* ATTENTION: This works with 0-based columns (as oposed to the regular 1-based columns)
*/
public static nextTabStop(visibleColumn: number, tabSize: number): number {
public static nextRenderTabStop(visibleColumn: number, tabSize: number): number {
return visibleColumn + tabSize - visibleColumn % tabSize;
}
/**
* ATTENTION: This works with 0-based columns (as oposed to the regular 1-based columns)
*/
public static prevTabStop(column: number, tabSize: number): number {
public static nextIndentTabStop(visibleColumn: number, indentSize: number): number {
return visibleColumn + indentSize - visibleColumn % indentSize;
}
/**
* ATTENTION: This works with 0-based columns (as oposed to the regular 1-based columns)
*/
public static prevRenderTabStop(column: number, tabSize: number): number {
return column - 1 - (column - 1) % tabSize;
}
/**
* ATTENTION: This works with 0-based columns (as oposed to the regular 1-based columns)
*/
public static prevIndentTabStop(column: number, indentSize: number): number {
return column - 1 - (column - 1) % indentSize;
}
}
export function isQuote(ch: string): boolean {

View File

@@ -131,7 +131,7 @@ export class DeleteOperations {
if (position.column <= lastIndentationColumn) {
let fromVisibleColumn = CursorColumns.visibleColumnFromColumn2(config, model, position);
let toVisibleColumn = CursorColumns.prevTabStop(fromVisibleColumn, config.tabSize);
let toVisibleColumn = CursorColumns.prevIndentTabStop(fromVisibleColumn, config.indentSize);
let toColumn = CursorColumns.columnFromVisibleColumn2(config, model, position.lineNumber, toVisibleColumn);
deleteSelection = new Range(position.lineNumber, toColumn, position.lineNumber, position.column);
} else {

View File

@@ -616,7 +616,29 @@ export namespace CursorMove {
* 'value': Number of units to move. Default is '1'.
* 'select': If 'true' makes the selection. Default is 'false'.
`,
constraint: isCursorMoveArgs
constraint: isCursorMoveArgs,
schema: {
'type': 'object',
'required': ['to'],
'properties': {
'to': {
'type': 'string',
'enum': ['left', 'right', 'up', 'down', 'wrappedLineStart', 'wrappedLineEnd', 'wrappedLineColumnCenter', 'wrappedLineFirstNonWhitespaceCharacter', 'wrappedLineLastNonWhitespaceCharacter', 'viewPortTop', 'viewPortCenter', 'viewPortBottom', 'viewPortIfOutside']
},
'by': {
'type': 'string',
'enum': ['line', 'wrappedLine', 'character', 'halfLine']
},
'value': {
'type': 'number',
'default': 1
},
'select': {
'type': 'boolean',
'default': false
}
}
}
}
]
};

View File

@@ -31,7 +31,8 @@ export class TypeOperations {
commands[i] = new ShiftCommand(selections[i], {
isUnshift: false,
tabSize: config.tabSize,
oneIndent: config.oneIndent,
indentSize: config.indentSize,
insertSpaces: config.insertSpaces,
useTabStops: config.useTabStops
});
}
@@ -44,7 +45,8 @@ export class TypeOperations {
commands[i] = new ShiftCommand(selections[i], {
isUnshift: true,
tabSize: config.tabSize,
oneIndent: config.oneIndent,
indentSize: config.indentSize,
insertSpaces: config.insertSpaces,
useTabStops: config.useTabStops
});
}
@@ -53,24 +55,12 @@ export class TypeOperations {
public static shiftIndent(config: CursorConfiguration, indentation: string, count?: number): string {
count = count || 1;
let desiredIndentCount = ShiftCommand.shiftIndentCount(indentation, indentation.length + count, config.tabSize);
let newIndentation = '';
for (let i = 0; i < desiredIndentCount; i++) {
newIndentation += '\t';
}
return newIndentation;
return ShiftCommand.shiftIndent(indentation, indentation.length + count, config.tabSize, config.indentSize, config.insertSpaces);
}
public static unshiftIndent(config: CursorConfiguration, indentation: string, count?: number): string {
count = count || 1;
let desiredIndentCount = ShiftCommand.unshiftIndentCount(indentation, indentation.length + count, config.tabSize);
let newIndentation = '';
for (let i = 0; i < desiredIndentCount; i++) {
newIndentation += '\t';
}
return newIndentation;
return ShiftCommand.unshiftIndent(indentation, indentation.length + count, config.tabSize, config.indentSize, config.insertSpaces);
}
private static _distributedPaste(config: CursorConfiguration, model: ICursorSimpleModel, selections: Selection[], text: string[]): EditOperationResult {
@@ -209,8 +199,8 @@ export class TypeOperations {
let position = selection.getStartPosition();
if (config.insertSpaces) {
let visibleColumnFromColumn = CursorColumns.visibleColumnFromColumn2(config, model, position);
let tabSize = config.tabSize;
let spacesCnt = tabSize - (visibleColumnFromColumn % tabSize);
let indentSize = config.indentSize;
let spacesCnt = indentSize - (visibleColumnFromColumn % indentSize);
for (let i = 0; i < spacesCnt; i++) {
typeText += ' ';
}
@@ -254,7 +244,8 @@ export class TypeOperations {
commands[i] = new ShiftCommand(selection, {
isUnshift: false,
tabSize: config.tabSize,
oneIndent: config.oneIndent,
indentSize: config.indentSize,
insertSpaces: config.insertSpaces,
useTabStops: config.useTabStops
});
}
@@ -377,7 +368,7 @@ export class TypeOperations {
let offset = 0;
if (oldEndColumn <= firstNonWhitespace + 1) {
if (!config.insertSpaces) {
oldEndViewColumn = Math.ceil(oldEndViewColumn / config.tabSize);
oldEndViewColumn = Math.ceil(oldEndViewColumn / config.indentSize);
}
offset = Math.min(oldEndViewColumn + 1 - config.normalizeIndentation(ir.afterEnter).length - 1, 0);
}
@@ -535,7 +526,7 @@ export class TypeOperations {
const lineText = model.getLineContent(position.lineNumber);
// Do not auto-close ' or " after a word character
if (chIsQuote && position.column > 1) {
if ((chIsQuote && position.column > 1) && autoCloseConfig !== 'always') {
const wordSeparators = getMapForWordSeparators(config.wordSeparators);
const characterBeforeCode = lineText.charCodeAt(position.column - 2);
const characterBeforeType = wordSeparators.get(characterBeforeCode);

View File

@@ -63,7 +63,7 @@ const enum Boolean {
export class CharacterSet {
private _actual: CharacterClassifier<Boolean>;
private readonly _actual: CharacterClassifier<Boolean>;
constructor() {
this._actual = new CharacterClassifier<Boolean>(Boolean.False);

View File

@@ -24,14 +24,14 @@ export class EditOperation {
};
}
public static replace(range: Range, text: string): IIdentifiedSingleEditOperation {
public static replace(range: Range, text: string | null): IIdentifiedSingleEditOperation {
return {
range: range,
text: text
};
}
public static replaceMove(range: Range, text: string): IIdentifiedSingleEditOperation {
public static replaceMove(range: Range, text: string | null): IIdentifiedSingleEditOperation {
return {
range: range,
text: text,

View File

@@ -5,7 +5,7 @@
export class Uint8Matrix {
private _data: Uint8Array;
private readonly _data: Uint8Array;
public readonly rows: number;
public readonly cols: number;

View File

@@ -469,7 +469,7 @@ export interface IDiffEditor extends IEditor {
/**
* Type the getModel() of IEditor.
*/
getModel(): IDiffEditorModel;
getModel(): IDiffEditorModel | null;
/**
* Get the `original` editor.

View File

@@ -12,7 +12,7 @@ import { IRange, Range } from 'vs/editor/common/core/range';
import { Selection } from 'vs/editor/common/core/selection';
import { IModelContentChange, IModelContentChangedEvent, IModelDecorationsChangedEvent, IModelLanguageChangedEvent, IModelLanguageConfigurationChangedEvent, IModelOptionsChangedEvent, IModelTokensChangedEvent, ModelRawContentChangedEvent } from 'vs/editor/common/model/textModelEvents';
import { SearchData } from 'vs/editor/common/model/textModelSearch';
import { LanguageId, LanguageIdentifier } from 'vs/editor/common/modes';
import { LanguageId, LanguageIdentifier, FormattingOptions } from 'vs/editor/common/modes';
import { ITextSnapshot } from 'vs/platform/files/common/files';
import { ThemeColor } from 'vs/platform/theme/common/themeService';
@@ -289,7 +289,7 @@ export interface ISingleEditOperation {
/**
* The text to replace with. This can be null to emulate a simple delete.
*/
text: string;
text: string | null;
/**
* This indicates that this operation has "insert" semantics.
* i.e. forceMoveMarkers = true => if `range` is collapsed, all markers at the position will be moved.
@@ -346,6 +346,7 @@ export class TextModelResolvedOptions {
_textModelResolvedOptionsBrand: void;
readonly tabSize: number;
readonly indentSize: number;
readonly insertSpaces: boolean;
readonly defaultEOL: DefaultEndOfLine;
readonly trimAutoWhitespace: boolean;
@@ -355,11 +356,13 @@ export class TextModelResolvedOptions {
*/
constructor(src: {
tabSize: number;
indentSize: number;
insertSpaces: boolean;
defaultEOL: DefaultEndOfLine;
trimAutoWhitespace: boolean;
}) {
this.tabSize = src.tabSize | 0;
this.indentSize = src.tabSize | 0;
this.insertSpaces = Boolean(src.insertSpaces);
this.defaultEOL = src.defaultEOL | 0;
this.trimAutoWhitespace = Boolean(src.trimAutoWhitespace);
@@ -371,6 +374,7 @@ export class TextModelResolvedOptions {
public equals(other: TextModelResolvedOptions): boolean {
return (
this.tabSize === other.tabSize
&& this.indentSize === other.indentSize
&& this.insertSpaces === other.insertSpaces
&& this.defaultEOL === other.defaultEOL
&& this.trimAutoWhitespace === other.trimAutoWhitespace
@@ -383,6 +387,7 @@ export class TextModelResolvedOptions {
public createChangeEvent(newOpts: TextModelResolvedOptions): IModelOptionsChangedEvent {
return {
tabSize: this.tabSize !== newOpts.tabSize,
indentSize: this.indentSize !== newOpts.indentSize,
insertSpaces: this.insertSpaces !== newOpts.insertSpaces,
trimAutoWhitespace: this.trimAutoWhitespace !== newOpts.trimAutoWhitespace,
};
@@ -394,6 +399,7 @@ export class TextModelResolvedOptions {
*/
export interface ITextModelCreationOptions {
tabSize: number;
indentSize: number;
insertSpaces: boolean;
detectIndentation: boolean;
trimAutoWhitespace: boolean;
@@ -404,6 +410,7 @@ export interface ITextModelCreationOptions {
export interface ITextModelUpdateOptions {
tabSize?: number;
indentSize?: number;
insertSpaces?: boolean;
trimAutoWhitespace?: boolean;
}
@@ -493,6 +500,12 @@ export interface ITextModel {
*/
getOptions(): TextModelResolvedOptions;
/**
* Get the formatting options for this model.
* @internal
*/
getFormattingOptions(): FormattingOptions;
/**
* Get the current version id of the model.
* Anytime a change happens to the model (even undo/redo),
@@ -951,11 +964,6 @@ export interface ITextModel {
*/
normalizeIndentation(str: string): string;
/**
* Get what is considered to be one indent (e.g. a tab character or 4 spaces, etc.).
*/
getOneIndent(): string;
/**
* Change the options of this model.
*/

View File

@@ -102,7 +102,7 @@ export interface IUndoRedoResult {
export class EditStack {
private model: TextModel;
private readonly model: TextModel;
private currentOpenStackElement: IStackElement | null;
private past: IStackElement[];
private future: IStackElement[];
@@ -210,7 +210,7 @@ export class EditStack {
}
public canUndo(): boolean {
return (this.past.length > 0);
return (this.past.length > 0) || this.currentOpenStackElement !== null;
}
public redo(): IUndoRedoResult | null {

View File

@@ -157,10 +157,10 @@ export class StringBuffer {
* 2. TreeNode/Buffers normalization should not happen during snapshot reading.
*/
class PieceTreeSnapshot implements ITextSnapshot {
private _pieces: Piece[];
private readonly _pieces: Piece[];
private _index: number;
private _tree: PieceTreeBase;
private _BOM: string;
private readonly _tree: PieceTreeBase;
private readonly _BOM: string;
constructor(tree: PieceTreeBase, BOM: string) {
this._pieces = [];
@@ -205,7 +205,7 @@ interface CacheEntry {
}
class PieceTreeSearchCache {
private _limit: number;
private readonly _limit: number;
private _cache: CacheEntry[];
constructor(limit: number) {

View File

@@ -27,8 +27,8 @@ export interface IReverseSingleEditOperation extends IIdentifiedSingleEditOperat
}
export class PieceTreeTextBuffer implements ITextBuffer {
private _pieceTree: PieceTreeBase;
private _BOM: string;
private readonly _pieceTree: PieceTreeBase;
private readonly _BOM: string;
private _mightContainRTL: boolean;
private _mightContainNonBasicASCII: boolean;

View File

@@ -62,12 +62,12 @@ export class PieceTreeTextBufferFactory implements ITextBufferFactory {
}
export class PieceTreeTextBufferBuilder implements ITextBufferBuilder {
private chunks: StringBuffer[];
private readonly chunks: StringBuffer[];
private BOM: string;
private _hasPreviousChar: boolean;
private _previousChar: number;
private _tmpLineStarts: number[];
private readonly _tmpLineStarts: number[];
private cr: number;
private lf: number;

View File

@@ -25,7 +25,7 @@ import { IModelContentChangedEvent, IModelDecorationsChangedEvent, IModelLanguag
import { SearchData, SearchParams, TextModelSearch } from 'vs/editor/common/model/textModelSearch';
import { ModelLinesTokens, ModelTokensChangedEventBuilder } from 'vs/editor/common/model/textModelTokens';
import { getWordAtText } from 'vs/editor/common/model/wordHelper';
import { IState, LanguageId, LanguageIdentifier, TokenizationRegistry } from 'vs/editor/common/modes';
import { IState, LanguageId, LanguageIdentifier, TokenizationRegistry, FormattingOptions } from 'vs/editor/common/modes';
import { LanguageConfigurationRegistry } from 'vs/editor/common/modes/languageConfigurationRegistry';
import { NULL_LANGUAGE_IDENTIFIER } from 'vs/editor/common/modes/nullMode';
import { ignoreBracketsInToken } from 'vs/editor/common/modes/supports';
@@ -163,6 +163,7 @@ export class TextModel extends Disposable implements model.ITextModel {
public static DEFAULT_CREATION_OPTIONS: model.ITextModelCreationOptions = {
isForSimpleWidget: false,
tabSize: EDITOR_MODEL_DEFAULTS.tabSize,
indentSize: EDITOR_MODEL_DEFAULTS.indentSize,
insertSpaces: EDITOR_MODEL_DEFAULTS.insertSpaces,
detectIndentation: false,
defaultEOL: model.DefaultEndOfLine.LF,
@@ -179,6 +180,7 @@ export class TextModel extends Disposable implements model.ITextModel {
const guessedIndentation = guessIndentation(textBuffer, options.tabSize, options.insertSpaces);
return new model.TextModelResolvedOptions({
tabSize: guessedIndentation.tabSize,
indentSize: guessedIndentation.tabSize, // TODO@Alex: guess indentSize independent of tabSize
insertSpaces: guessedIndentation.insertSpaces,
trimAutoWhitespace: options.trimAutoWhitespace,
defaultEOL: options.defaultEOL
@@ -187,6 +189,7 @@ export class TextModel extends Disposable implements model.ITextModel {
return new model.TextModelResolvedOptions({
tabSize: options.tabSize,
indentSize: options.indentSize,
insertSpaces: options.insertSpaces,
trimAutoWhitespace: options.trimAutoWhitespace,
defaultEOL: options.defaultEOL
@@ -262,8 +265,8 @@ export class TextModel extends Disposable implements model.ITextModel {
//#region Tokenization
private _languageIdentifier: LanguageIdentifier;
private _tokenizationListener: IDisposable;
private _languageRegistryListener: IDisposable;
private readonly _tokenizationListener: IDisposable;
private readonly _languageRegistryListener: IDisposable;
private _revalidateTokensTimeout: any;
/*private*/_tokens: ModelLinesTokens;
//#endregion
@@ -587,14 +590,23 @@ export class TextModel extends Disposable implements model.ITextModel {
return this._options;
}
public getFormattingOptions(): FormattingOptions {
return {
tabSize: this._options.indentSize,
insertSpaces: this._options.insertSpaces
};
}
public updateOptions(_newOpts: model.ITextModelUpdateOptions): void {
this._assertNotDisposed();
let tabSize = (typeof _newOpts.tabSize !== 'undefined') ? _newOpts.tabSize : this._options.tabSize;
let indentSize = (typeof _newOpts.indentSize !== 'undefined') ? _newOpts.indentSize : this._options.indentSize;
let insertSpaces = (typeof _newOpts.insertSpaces !== 'undefined') ? _newOpts.insertSpaces : this._options.insertSpaces;
let trimAutoWhitespace = (typeof _newOpts.trimAutoWhitespace !== 'undefined') ? _newOpts.trimAutoWhitespace : this._options.trimAutoWhitespace;
let newOpts = new model.TextModelResolvedOptions({
tabSize: tabSize,
indentSize: indentSize,
insertSpaces: insertSpaces,
defaultEOL: this._options.defaultEOL,
trimAutoWhitespace: trimAutoWhitespace
@@ -615,15 +627,16 @@ export class TextModel extends Disposable implements model.ITextModel {
let guessedIndentation = guessIndentation(this._buffer, defaultTabSize, defaultInsertSpaces);
this.updateOptions({
insertSpaces: guessedIndentation.insertSpaces,
tabSize: guessedIndentation.tabSize
tabSize: guessedIndentation.tabSize,
indentSize: guessedIndentation.tabSize, // TODO@Alex: guess indentSize independent of tabSize
});
}
private static _normalizeIndentationFromWhitespace(str: string, tabSize: number, insertSpaces: boolean): string {
private static _normalizeIndentationFromWhitespace(str: string, indentSize: number, insertSpaces: boolean): string {
let spacesCnt = 0;
for (let i = 0; i < str.length; i++) {
if (str.charAt(i) === '\t') {
spacesCnt += tabSize;
spacesCnt += indentSize;
} else {
spacesCnt++;
}
@@ -631,8 +644,8 @@ export class TextModel extends Disposable implements model.ITextModel {
let result = '';
if (!insertSpaces) {
let tabsCnt = Math.floor(spacesCnt / tabSize);
spacesCnt = spacesCnt % tabSize;
let tabsCnt = Math.floor(spacesCnt / indentSize);
spacesCnt = spacesCnt % indentSize;
for (let i = 0; i < tabsCnt; i++) {
result += '\t';
}
@@ -645,33 +658,17 @@ export class TextModel extends Disposable implements model.ITextModel {
return result;
}
public static normalizeIndentation(str: string, tabSize: number, insertSpaces: boolean): string {
public static normalizeIndentation(str: string, indentSize: number, insertSpaces: boolean): string {
let firstNonWhitespaceIndex = strings.firstNonWhitespaceIndex(str);
if (firstNonWhitespaceIndex === -1) {
firstNonWhitespaceIndex = str.length;
}
return TextModel._normalizeIndentationFromWhitespace(str.substring(0, firstNonWhitespaceIndex), tabSize, insertSpaces) + str.substring(firstNonWhitespaceIndex);
return TextModel._normalizeIndentationFromWhitespace(str.substring(0, firstNonWhitespaceIndex), indentSize, insertSpaces) + str.substring(firstNonWhitespaceIndex);
}
public normalizeIndentation(str: string): string {
this._assertNotDisposed();
return TextModel.normalizeIndentation(str, this._options.tabSize, this._options.insertSpaces);
}
public getOneIndent(): string {
this._assertNotDisposed();
let tabSize = this._options.tabSize;
let insertSpaces = this._options.insertSpaces;
if (insertSpaces) {
let result = '';
for (let i = 0; i < tabSize; i++) {
result += ' ';
}
return result;
} else {
return '\t';
}
return TextModel.normalizeIndentation(str, this._options.indentSize, this._options.insertSpaces);
}
//#endregion
@@ -2574,7 +2571,7 @@ export class TextModel extends Disposable implements model.ITextModel {
// Use the line's indent
up_belowContentLineIndex = upLineNumber - 1;
up_belowContentLineIndent = currentIndent;
upLineIndentLevel = Math.ceil(currentIndent / this._options.tabSize);
upLineIndentLevel = Math.ceil(currentIndent / this._options.indentSize);
} else {
up_resolveIndents(upLineNumber);
upLineIndentLevel = this._getIndentLevelForWhitespaceLine(offSide, up_aboveContentLineIndent, up_belowContentLineIndent);
@@ -2609,7 +2606,7 @@ export class TextModel extends Disposable implements model.ITextModel {
// Use the line's indent
down_aboveContentLineIndex = downLineNumber - 1;
down_aboveContentLineIndent = currentIndent;
downLineIndentLevel = Math.ceil(currentIndent / this._options.tabSize);
downLineIndentLevel = Math.ceil(currentIndent / this._options.indentSize);
} else {
down_resolveIndents(downLineNumber);
downLineIndentLevel = this._getIndentLevelForWhitespaceLine(offSide, down_aboveContentLineIndent, down_belowContentLineIndent);
@@ -2657,7 +2654,7 @@ export class TextModel extends Disposable implements model.ITextModel {
// Use the line's indent
aboveContentLineIndex = lineNumber - 1;
aboveContentLineIndent = currentIndent;
result[resultIndex] = Math.ceil(currentIndent / this._options.tabSize);
result[resultIndex] = Math.ceil(currentIndent / this._options.indentSize);
continue;
}
@@ -2704,20 +2701,20 @@ export class TextModel extends Disposable implements model.ITextModel {
} else if (aboveContentLineIndent < belowContentLineIndent) {
// we are inside the region above
return (1 + Math.floor(aboveContentLineIndent / this._options.tabSize));
return (1 + Math.floor(aboveContentLineIndent / this._options.indentSize));
} else if (aboveContentLineIndent === belowContentLineIndent) {
// we are in between two regions
return Math.ceil(belowContentLineIndent / this._options.tabSize);
return Math.ceil(belowContentLineIndent / this._options.indentSize);
} else {
if (offSide) {
// same level as region below
return Math.ceil(belowContentLineIndent / this._options.tabSize);
return Math.ceil(belowContentLineIndent / this._options.indentSize);
} else {
// we are inside the region that ends below
return (1 + Math.floor(belowContentLineIndent / this._options.tabSize));
return (1 + Math.floor(belowContentLineIndent / this._options.indentSize));
}
}
@@ -2733,12 +2730,12 @@ class DecorationsTrees {
/**
* This tree holds decorations that do not show up in the overview ruler.
*/
private _decorationsTree0: IntervalTree;
private readonly _decorationsTree0: IntervalTree;
/**
* This tree holds decorations that show up in the overview ruler.
*/
private _decorationsTree1: IntervalTree;
private readonly _decorationsTree1: IntervalTree;
constructor() {
this._decorationsTree0 = new IntervalTree();

View File

@@ -97,6 +97,7 @@ export interface IModelTokensChangedEvent {
export interface IModelOptionsChangedEvent {
readonly tabSize: boolean;
readonly indentSize: boolean;
readonly insertSpaces: boolean;
readonly trimAutoWhitespace: boolean;
}

View File

@@ -509,8 +509,8 @@ export function isValidMatch(wordSeparators: WordCharacterClassifier, text: stri
}
export class Searcher {
private _wordSeparators: WordCharacterClassifier | null;
private _searchRegex: RegExp;
private readonly _wordSeparators: WordCharacterClassifier | null;
private readonly _searchRegex: RegExp;
private _prevMatchStartIndex: number;
private _prevMatchLength: number;

View File

@@ -472,7 +472,7 @@ export class ModelLinesTokens {
export class ModelTokensChangedEventBuilder {
private _ranges: { fromLineNumber: number; toLineNumber: number; }[];
private readonly _ranges: { fromLineNumber: number; toLineNumber: number; }[];
constructor() {
this._ranges = [];

View File

@@ -9,7 +9,7 @@ import { Event } from 'vs/base/common/event';
import { IMarkdownString } from 'vs/base/common/htmlContent';
import { IDisposable } from 'vs/base/common/lifecycle';
import { isObject } from 'vs/base/common/types';
import { URI } from 'vs/base/common/uri';
import { URI, UriComponents } from 'vs/base/common/uri';
import { Position } from 'vs/editor/common/core/position';
import { IRange, Range } from 'vs/editor/common/core/range';
import { Selection } from 'vs/editor/common/core/selection';
@@ -18,6 +18,7 @@ import * as model from 'vs/editor/common/model';
import { LanguageFeatureRegistry } from 'vs/editor/common/modes/languageFeatureRegistry';
import { TokenizationRegistryImpl } from 'vs/editor/common/modes/tokenizationRegistry';
import { IMarkerData } from 'vs/platform/markers/common/markers';
import { ExtensionIdentifier } from 'vs/platform/extensions/common/extensions';
/**
* Open ended enum at runtime
@@ -286,7 +287,7 @@ export const enum CompletionItemKind {
/**
* @internal
*/
export let completionKindToCssClass = (function () {
export const completionKindToCssClass = (function () {
let data = Object.create(null);
data[CompletionItemKind.Method] = 'method';
data[CompletionItemKind.Function] = 'function';
@@ -323,11 +324,14 @@ export let completionKindToCssClass = (function () {
/**
* @internal
*/
export let completionKindFromLegacyString = (function () {
let data = Object.create(null);
export let completionKindFromString: {
(value: string): CompletionItemKind;
(value: string, strict: true): CompletionItemKind | undefined;
} = (function () {
let data: Record<string, CompletionItemKind> = Object.create(null);
data['method'] = CompletionItemKind.Method;
data['function'] = CompletionItemKind.Function;
data['constructor'] = CompletionItemKind.Constructor;
data['constructor'] = <any>CompletionItemKind.Constructor;
data['field'] = CompletionItemKind.Field;
data['variable'] = CompletionItemKind.Variable;
data['class'] = CompletionItemKind.Class;
@@ -342,6 +346,7 @@ export let completionKindFromLegacyString = (function () {
data['constant'] = CompletionItemKind.Constant;
data['enum'] = CompletionItemKind.Enum;
data['enum-member'] = CompletionItemKind.EnumMember;
data['enumMember'] = CompletionItemKind.EnumMember;
data['keyword'] = CompletionItemKind.Keyword;
data['snippet'] = CompletionItemKind.Snippet;
data['text'] = CompletionItemKind.Text;
@@ -351,9 +356,14 @@ export let completionKindFromLegacyString = (function () {
data['customcolor'] = CompletionItemKind.Customcolor;
data['folder'] = CompletionItemKind.Folder;
data['type-parameter'] = CompletionItemKind.TypeParameter;
data['typeParameter'] = CompletionItemKind.TypeParameter;
return function (value: string) {
return data[value] || 'property';
return function (value: string, strict?: true) {
let res = data[value];
if (typeof res === 'undefined' && !strict) {
res = CompletionItemKind.Property;
}
return res;
};
})();
@@ -667,7 +677,7 @@ export interface DocumentHighlight {
/**
* The highlight kind, default is [text](#DocumentHighlightKind.Text).
*/
kind: DocumentHighlightKind;
kind?: DocumentHighlightKind;
}
/**
* The document highlight provider interface defines the contract between extensions and
@@ -864,8 +874,8 @@ export const symbolKindToCssClass = (function () {
_fromMapping[SymbolKind.Operator] = 'operator';
_fromMapping[SymbolKind.TypeParameter] = 'type-parameter';
return function toCssClassName(kind: SymbolKind): string {
return `symbol-icon ${_fromMapping[kind] || 'property'}`;
return function toCssClassName(kind: SymbolKind, inline?: boolean): string {
return `symbol-icon ${inline ? 'inline' : 'block'} ${_fromMapping[kind] || 'property'}`;
};
})();
@@ -914,7 +924,10 @@ export interface FormattingOptions {
*/
export interface DocumentFormattingEditProvider {
displayName?: string;
/**
* @internal
*/
readonly extensionId?: ExtensionIdentifier;
/**
* Provide formatting edits for a whole document.
@@ -927,7 +940,11 @@ export interface DocumentFormattingEditProvider {
*/
export interface DocumentRangeFormattingEditProvider {
displayName?: string;
/**
* @internal
*/
readonly extensionId?: ExtensionIdentifier;
/**
* Provide formatting edits for a range in a document.
@@ -943,7 +960,15 @@ export interface DocumentRangeFormattingEditProvider {
* the formatting-feature.
*/
export interface OnTypeFormattingEditProvider {
/**
* @internal
*/
readonly extensionId?: ExtensionIdentifier;
autoFormatTriggerCharacters: string[];
/**
* Provide formatting edits after a character has been typed.
*
@@ -967,7 +992,7 @@ export interface IInplaceReplaceSupportResult {
*/
export interface ILink {
range: IRange;
url?: string;
url?: URI | string;
}
/**
* A provider of links.
@@ -1064,7 +1089,7 @@ export interface SelectionRangeProvider {
/**
* Provide ranges that should be selected from the given position.
*/
provideSelectionRanges(model: model.ITextModel, position: Position, token: CancellationToken): ProviderResult<SelectionRange[]>;
provideSelectionRanges(model: model.ITextModel, positions: Position[], token: CancellationToken): ProviderResult<SelectionRange[][]>;
}
export interface FoldingContext {
@@ -1178,11 +1203,11 @@ export interface Command {
* @internal
*/
export interface CommentInfo {
extensionId: string;
extensionId?: string;
threads: CommentThread[];
commentingRanges?: IRange[];
commentingRanges?: (IRange[] | CommentingRanges);
reply?: Command;
draftMode: DraftMode;
draftMode?: DraftMode;
}
/**
@@ -1208,13 +1233,68 @@ export enum CommentThreadCollapsibleState {
Expanded = 1
}
/**
* @internal
*/
export interface CommentWidget {
commentThread: CommentThread;
comment?: Comment;
input: string;
onDidChangeInput: Event<string>;
}
/**
* @internal
*/
export interface CommentInput {
value: string;
uri: URI;
}
/**
* @internal
*/
export interface CommentThread2 {
commentThreadHandle: number;
extensionId?: string;
threadId: string | null;
resource: string | null;
range: IRange;
label: string;
comments: Comment[];
onDidChangeComments: Event<Comment[]>;
collapsibleState?: CommentThreadCollapsibleState;
input?: CommentInput;
onDidChangeInput: Event<CommentInput | undefined>;
acceptInputCommand?: Command;
additionalCommands: Command[];
onDidChangeAcceptInputCommand: Event<Command>;
onDidChangeAdditionalCommands: Event<Command[]>;
onDidChangeRange: Event<IRange>;
onDidChangeLabel: Event<string>;
onDidChangeCollasibleState: Event<CommentThreadCollapsibleState>;
}
/**
* @internal
*/
export interface CommentingRanges {
readonly resource: URI;
ranges: IRange[];
newCommentThreadCommand?: Command;
newCommentThreadCallback?: (uri: UriComponents, range: IRange) => void;
}
/**
* @internal
*/
export interface CommentThread {
extensionId: string;
threadId: string;
resource: string;
extensionId?: string;
threadId: string | null;
resource: string | null;
range: IRange;
comments: Comment[];
collapsibleState?: CommentThreadCollapsibleState;
@@ -1234,7 +1314,10 @@ export interface NewCommentAction {
*/
export interface CommentReaction {
readonly label?: string;
readonly iconPath?: UriComponents;
readonly count?: number;
readonly hasReacted?: boolean;
readonly canEdit?: boolean;
}
/**
@@ -1244,12 +1327,15 @@ export interface Comment {
readonly commentId: string;
readonly body: IMarkdownString;
readonly userName: string;
readonly userIconPath: string;
readonly userIconPath?: string;
readonly canEdit?: boolean;
readonly canDelete?: boolean;
readonly command?: Command;
readonly selectCommand?: Command;
readonly editCommand?: Command;
readonly deleteCommand?: Command;
readonly isDraft?: boolean;
readonly commentReactions?: CommentReaction[];
readonly label?: string;
}
/**
@@ -1259,31 +1345,31 @@ export interface CommentThreadChangedEvent {
/**
* Added comment threads.
*/
readonly added: CommentThread[];
readonly added: (CommentThread | CommentThread2)[];
/**
* Removed comment threads.
*/
readonly removed: CommentThread[];
readonly removed: (CommentThread | CommentThread2)[];
/**
* Changed comment threads.
*/
readonly changed: CommentThread[];
readonly changed: (CommentThread | CommentThread2)[];
/**
* changed draft mode.
*/
readonly draftMode: DraftMode;
readonly draftMode?: DraftMode;
}
/**
* @internal
*/
export interface DocumentCommentProvider {
provideDocumentComments(resource: URI, token: CancellationToken): Promise<CommentInfo>;
createNewCommentThread(resource: URI, range: Range, text: string, token: CancellationToken): Promise<CommentThread>;
replyToCommentThread(resource: URI, range: Range, thread: CommentThread, text: string, token: CancellationToken): Promise<CommentThread>;
provideDocumentComments(resource: URI, token: CancellationToken): Promise<CommentInfo | null>;
createNewCommentThread(resource: URI, range: Range, text: string, token: CancellationToken): Promise<CommentThread | null>;
replyToCommentThread(resource: URI, range: Range, thread: CommentThread, text: string, token: CancellationToken): Promise<CommentThread | null>;
editComment(resource: URI, comment: Comment, text: string, token: CancellationToken): Promise<void>;
deleteComment(resource: URI, comment: Comment, token: CancellationToken): Promise<void>;
startDraft?(resource: URI, token: CancellationToken): Promise<void>;
@@ -1298,7 +1384,7 @@ export interface DocumentCommentProvider {
deleteReaction?(resource: URI, comment: Comment, reaction: CommentReaction, token: CancellationToken): Promise<void>;
reactionGroup?: CommentReaction[];
onDidChangeCommentThreads(): Event<CommentThreadChangedEvent>;
onDidChangeCommentThreads?(): Event<CommentThreadChangedEvent>;
}
/**

View File

@@ -7,7 +7,7 @@ import { IMode, LanguageIdentifier } from 'vs/editor/common/modes';
export class FrankensteinMode implements IMode {
private _languageIdentifier: LanguageIdentifier;
private readonly _languageIdentifier: LanguageIdentifier;
constructor(languageIdentifier: LanguageIdentifier) {
this._languageIdentifier = languageIdentifier;

View File

@@ -170,7 +170,7 @@ export interface IDocComment {
/**
* The string that appears on the last line and closes the doc comment (e.g. ' * /').
*/
close: string;
close?: string;
}
/**

View File

@@ -175,7 +175,7 @@ export class LanguageConfigurationChangeEvent {
export class LanguageConfigurationRegistryImpl {
private _entries: RichEditSupport[];
private readonly _entries: RichEditSupport[];
private readonly _onDidChange = new Emitter<LanguageConfigurationChangeEvent>();
public readonly onDidChange: Event<LanguageConfigurationChangeEvent> = this._onDidChange.event;

View File

@@ -29,7 +29,7 @@ function isExclusive(selector: LanguageSelector): boolean {
export class LanguageFeatureRegistry<T> {
private _clock: number = 0;
private _entries: Entry<T>[] = [];
private readonly _entries: Entry<T>[] = [];
private readonly _onDidChange = new Emitter<number>();
constructor() {

View File

@@ -19,7 +19,7 @@ export interface LanguageFilter {
export type LanguageSelector = string | LanguageFilter | Array<string | LanguageFilter>;
export function score(selector: LanguageSelector, candidateUri: URI, candidateLanguage: string, candidateIsSynchronized: boolean): number {
export function score(selector: LanguageSelector | undefined, candidateUri: URI, candidateLanguage: string, candidateIsSynchronized: boolean): number {
if (Array.isArray(selector)) {
// array -> take max individual value

View File

@@ -35,8 +35,8 @@ export type Edge = [State, number, State];
export class StateMachine {
private _states: Uint8Matrix;
private _maxCharCode: number;
private readonly _states: Uint8Matrix;
private readonly _maxCharCode: number;
constructor(edges: Edge[]) {
let maxCharCode = 0;

View File

@@ -17,7 +17,7 @@ export const Extensions = {
export class EditorModesRegistry {
private _languages: ILanguageExtensionPoint[];
private readonly _languages: ILanguageExtensionPoint[];
private _dynamicLanguages: ILanguageExtensionPoint[];
private readonly _onDidChangeLanguages = new Emitter<void>();

View File

@@ -33,7 +33,7 @@ export class BracketElectricCharacterSupport {
this._complexAutoClosePairs = autoClosePairs.filter(pair => pair.open.length > 1 && !!pair.close).map(el => new StandardAutoClosingPairConditional(el));
if (contribution.docComment) {
// IDocComment is legacy, only partially supported
this._complexAutoClosePairs.push(new StandardAutoClosingPairConditional({ open: contribution.docComment.open, close: contribution.docComment.close }));
this._complexAutoClosePairs.push(new StandardAutoClosingPairConditional({ open: contribution.docComment.open, close: contribution.docComment.close || '' }));
}
}

View File

@@ -64,7 +64,7 @@ export class BasicInplaceReplace {
return null;
}
private _defaultValueSet: string[][] = [
private readonly _defaultValueSet: string[][] = [
['true', 'false'],
['True', 'False'],
['Private', 'Public', 'Friend', 'ReadOnly', 'Partial', 'Protected', 'WriteOnly'],

View File

@@ -151,8 +151,8 @@ const colorRegExp = /^#?([0-9A-Fa-f]{6})([0-9A-Fa-f]{2})?$/;
export class ColorMap {
private _lastColorId: number;
private _id2color: Color[];
private _color2id: Map<string, ColorId>;
private readonly _id2color: Color[];
private readonly _color2id: Map<string, ColorId>;
constructor() {
this._lastColorId = 0;
@@ -240,7 +240,7 @@ export class TokenTheme {
}
}
const STANDARD_TOKEN_TYPE_REGEXP = /\b(comment|string|regex)\b/;
const STANDARD_TOKEN_TYPE_REGEXP = /\b(comment|string|regex|regexp)\b/;
export function toStandardTokenType(tokenType: string): StandardTokenType {
let m = tokenType.match(STANDARD_TOKEN_TYPE_REGEXP);
if (!m) {
@@ -253,6 +253,8 @@ export function toStandardTokenType(tokenType: string): StandardTokenType {
return StandardTokenType.String;
case 'regex':
return StandardTokenType.RegEx;
case 'regexp':
return StandardTokenType.RegEx;
}
throw new Error('Unexpected match for standard token type!');
}

View File

@@ -10,8 +10,8 @@ import { ColorId, ITokenizationRegistry, ITokenizationSupport, ITokenizationSupp
export class TokenizationRegistryImpl implements ITokenizationRegistry {
private _map: { [language: string]: ITokenizationSupport };
private _promises: { [language: string]: Thenable<void> };
private readonly _map: { [language: string]: ITokenizationSupport };
private readonly _promises: { [language: string]: Thenable<void> };
private readonly _onDidChange = new Emitter<ITokenizationSupportChangedEvent>();
public readonly onDidChange: Event<ITokenizationSupportChangedEvent> = this._onDidChange.event;

View File

@@ -22,6 +22,7 @@ import { ILinkComputerTarget, computeLinks } from 'vs/editor/common/modes/linkCo
import { BasicInplaceReplace } from 'vs/editor/common/modes/supports/inplaceReplaceSupport';
import { IDiffComputationResult } from 'vs/editor/common/services/editorWorkerService';
import { createMonacoBaseAPI } from 'vs/editor/common/standalone/standaloneBase';
import { getAllPropertyNames } from 'vs/base/common/types';
export interface IMirrorModel {
readonly uri: URI;
@@ -322,7 +323,7 @@ declare var require: any;
* @internal
*/
export abstract class BaseEditorSimpleWorker {
private _foreignModuleFactory: IForeignModuleFactory | null;
private readonly _foreignModuleFactory: IForeignModuleFactory | null;
private _foreignModule: any;
constructor(foreignModuleFactory: IForeignModuleFactory | null) {
@@ -490,12 +491,15 @@ export abstract class BaseEditorSimpleWorker {
return Promise.resolve(null);
}
const seen: Record<string, boolean> = Object.create(null);
const suggestions: CompletionItem[] = [];
const wordDefRegExp = new RegExp(wordDef, wordDefFlags);
const currentWord = model.getWordUntilPosition(position, wordDefRegExp);
const wordUntil = model.getWordUntilPosition(position, wordDefRegExp);
const seen: Record<string, boolean> = Object.create(null);
seen[currentWord.word] = true;
const wordAt = model.getWordAtPosition(position, wordDefRegExp);
if (wordAt) {
seen[model.getValueInRange(wordAt)] = true;
}
for (
let iter = model.createWordIterator(wordDefRegExp), e = iter.next();
@@ -515,10 +519,9 @@ export abstract class BaseEditorSimpleWorker {
kind: CompletionItemKind.Text,
label: word,
insertText: word,
range: { startLineNumber: position.lineNumber, startColumn: currentWord.startColumn, endLineNumber: position.lineNumber, endColumn: currentWord.endColumn }
range: { startLineNumber: position.lineNumber, startColumn: wordUntil.startColumn, endLineNumber: position.lineNumber, endColumn: wordUntil.endColumn }
});
}
return Promise.resolve({ suggestions });
}
@@ -599,7 +602,7 @@ export abstract class BaseEditorSimpleWorker {
this._foreignModule = this._foreignModuleFactory(ctx, createData);
// static foreing module
let methods: string[] = [];
for (let prop in this._foreignModule) {
for (const prop of getAllPropertyNames(this._foreignModule)) {
if (typeof this._foreignModule[prop] === 'function') {
methods.push(prop);
}
@@ -612,7 +615,7 @@ export abstract class BaseEditorSimpleWorker {
this._foreignModule = foreignModule.create(ctx, createData);
let methods: string[] = [];
for (let prop in this._foreignModule) {
for (const prop of getAllPropertyNames(this._foreignModule)) {
if (typeof this._foreignModule[prop] === 'function') {
methods.push(prop);
}

View File

@@ -146,7 +146,7 @@ class WordBasedCompletionItemProvider implements modes.CompletionItemProvider {
class WorkerManager extends Disposable {
private _modelService: IModelService;
private readonly _modelService: IModelService;
private _editorWorkerClient: EditorWorkerClient | null;
private _lastWorkerUsedTime: number;
@@ -211,8 +211,8 @@ class WorkerManager extends Disposable {
class EditorModelManager extends Disposable {
private _proxy: EditorSimpleWorkerImpl;
private _modelService: IModelService;
private readonly _proxy: EditorSimpleWorkerImpl;
private readonly _modelService: IModelService;
private _syncedModels: { [modelUrl: string]: IDisposable[]; } = Object.create(null);
private _syncedModelsLastUsedTime: { [modelUrl: string]: number; } = Object.create(null);
@@ -312,8 +312,8 @@ interface IWorkerClient<T> {
}
class SynchronousWorkerClient<T extends IDisposable> implements IWorkerClient<T> {
private _instance: T;
private _proxyObj: Promise<T>;
private readonly _instance: T;
private readonly _proxyObj: Promise<T>;
constructor(instance: T) {
this._instance = instance;
@@ -331,9 +331,9 @@ class SynchronousWorkerClient<T extends IDisposable> implements IWorkerClient<T>
export class EditorWorkerClient extends Disposable {
private _modelService: IModelService;
private readonly _modelService: IModelService;
private _worker: IWorkerClient<EditorSimpleWorkerImpl> | null;
private _workerFactory: DefaultWorkerFactory;
private readonly _workerFactory: DefaultWorkerFactory;
private _modelManager: EditorModelManager | null;
constructor(modelService: IModelService, label: string | undefined) {

View File

@@ -12,9 +12,11 @@ import { IModelService } from 'vs/editor/common/services/modelService';
import { FileKind } from 'vs/platform/files/common/files';
export function getIconClasses(modelService: IModelService, modeService: IModeService, resource: uri | undefined, fileKind?: FileKind): string[] {
// we always set these base classes even if we do not have a path
const classes = fileKind === FileKind.ROOT_FOLDER ? ['rootfolder-icon'] : fileKind === FileKind.FOLDER ? ['folder-icon'] : ['file-icon'];
if (resource) {
// Get the path and name of the resource. For data-URIs, we need to parse specially
let name: string | undefined;
let path: string | undefined;
@@ -22,17 +24,19 @@ export function getIconClasses(modelService: IModelService, modeService: IModeSe
const metadata = DataUri.parseMetaData(resource);
name = metadata.get(DataUri.META_DATA_LABEL);
path = name;
}
else {
} else {
name = cssEscape(basenameOrAuthority(resource).toLowerCase());
path = resource.path.toLowerCase();
}
// Folders
if (fileKind === FileKind.FOLDER) {
classes.push(`${name}-name-folder-icon`);
}
// Files
else {
// Name & Extension(s)
if (name) {
classes.push(`${name}-name-file-icon`);
@@ -42,8 +46,9 @@ export function getIconClasses(modelService: IModelService, modeService: IModeSe
}
classes.push(`ext-file-icon`); // extra segment to increase file-ext score
}
// Configured Language
let configuredLangId: string | null = getConfiguredLangId(modelService, resource);
let configuredLangId: string | null = getConfiguredLangId(modelService, modeService, resource);
configuredLangId = configuredLangId || (path ? modeService.getModeIdByFilepathOrFirstLine(path) : null);
if (configuredLangId) {
classes.push(`${cssEscape(configuredLangId)}-lang-file-icon`);
@@ -53,16 +58,32 @@ export function getIconClasses(modelService: IModelService, modeService: IModeSe
return classes;
}
export function getConfiguredLangId(modelService: IModelService, resource: uri): string | null {
export function getConfiguredLangId(modelService: IModelService, modeService: IModeService, resource: uri): string | null {
let configuredLangId: string | null = null;
if (resource) {
const model = modelService.getModel(resource);
if (model) {
const modeId = model.getLanguageIdentifier().language;
if (modeId && modeId !== PLAINTEXT_MODE_ID) {
configuredLangId = modeId; // only take if the mode is specific (aka no just plain text)
let modeId: string | null = null;
// Data URI: check for encoded metadata
if (resource.scheme === Schemas.data) {
const metadata = DataUri.parseMetaData(resource);
const mime = metadata.get(DataUri.META_DATA_MIME);
if (mime) {
modeId = modeService.getModeId(mime);
}
}
// Any other URI: check for model if existing
else {
const model = modelService.getModel(resource);
if (model) {
modeId = model.getLanguageIdentifier().language;
}
}
if (modeId && modeId !== PLAINTEXT_MODE_ID) {
configuredLangId = modeId; // only take if the mode is specific (aka no just plain text)
}
}
return configuredLangId;

View File

@@ -36,8 +36,8 @@ export class LanguagesRegistry extends Disposable {
private readonly _warnOnOverwrite: boolean;
private _nextLanguageId2: number;
private _languageIdToLanguage: string[];
private _languageToLanguageId: { [id: string]: number; };
private readonly _languageIdToLanguage: string[];
private readonly _languageToLanguageId: { [id: string]: number; };
private _languages: { [id: string]: IResolvedLanguage; };
private _mimeTypesMap: { [mimeType: string]: LanguageIdentifier; };
@@ -273,7 +273,7 @@ export class LanguagesRegistry extends Disposable {
return (language.mimetypes[0] || null);
}
public extractModeIds(commaSeparatedMimetypesOrCommaSeparatedIds: string): string[] {
public extractModeIds(commaSeparatedMimetypesOrCommaSeparatedIds: string | undefined): string[] {
if (!commaSeparatedMimetypesOrCommaSeparatedIds) {
return [];
}

View File

@@ -15,6 +15,7 @@ import { Range } from 'vs/editor/common/core/range';
import { keys } from 'vs/base/common/map';
import { IMarkerDecorationsService } from 'vs/editor/common/services/markersDecorationService';
import { Schemas } from 'vs/base/common/network';
import { Emitter, Event } from 'vs/base/common/event';
function MODEL_ID(resource: URI): string {
return resource.toString();
@@ -44,12 +45,26 @@ class MarkerDecorations extends Disposable {
getMarker(decoration: IModelDecoration): IMarker | undefined {
return this._markersData.get(decoration.id);
}
getMarkers(): [Range, IMarker][] {
const res: [Range, IMarker][] = [];
this._markersData.forEach((marker, id) => {
let range = this.model.getDecorationRange(id);
if (range) {
res.push([range, marker]);
}
});
return res;
}
}
export class MarkerDecorationsService extends Disposable implements IMarkerDecorationsService {
_serviceBrand: any;
private readonly _onDidChangeMarker = new Emitter<ITextModel>();
readonly onDidChangeMarker: Event<ITextModel> = this._onDidChangeMarker.event;
private readonly _markerDecorations: Map<string, MarkerDecorations> = new Map<string, MarkerDecorations>();
constructor(
@@ -68,11 +83,16 @@ export class MarkerDecorationsService extends Disposable implements IMarkerDecor
return markerDecorations ? markerDecorations.getMarker(decoration) || null : null;
}
getLiveMarkers(model: ITextModel): [Range, IMarker][] {
const markerDecorations = this._markerDecorations.get(MODEL_ID(model.uri));
return markerDecorations ? markerDecorations.getMarkers() : [];
}
private _handleMarkerChange(changedResources: URI[]): void {
changedResources.forEach((resource) => {
const markerDecorations = this._markerDecorations.get(MODEL_ID(resource));
if (markerDecorations) {
this.updateDecorations(markerDecorations);
this._updateDecorations(markerDecorations);
}
});
}
@@ -80,7 +100,7 @@ export class MarkerDecorationsService extends Disposable implements IMarkerDecor
private _onModelAdded(model: ITextModel): void {
const markerDecorations = new MarkerDecorations(model);
this._markerDecorations.set(MODEL_ID(model.uri), markerDecorations);
this.updateDecorations(markerDecorations);
this._updateDecorations(markerDecorations);
}
private _onModelRemoved(model: ITextModel): void {
@@ -100,7 +120,7 @@ export class MarkerDecorationsService extends Disposable implements IMarkerDecor
}
}
private updateDecorations(markerDecorations: MarkerDecorations): void {
private _updateDecorations(markerDecorations: MarkerDecorations): void {
// Limit to the first 500 errors/warnings
const markers = this._markerService.read({ resource: markerDecorations.model.uri, take: 500 });
let newModelDecorations: IModelDeltaDecoration[] = markers.map((marker) => {
@@ -110,6 +130,7 @@ export class MarkerDecorationsService extends Disposable implements IMarkerDecor
};
});
markerDecorations.update(markers, newModelDecorations);
this._onDidChangeMarker.fire(markerDecorations.model);
}
private _createDecorationRange(model: ITextModel, rawMarker: IMarker): Range {

View File

@@ -6,11 +6,17 @@
import { ITextModel, IModelDecoration } from 'vs/editor/common/model';
import { createDecorator } from 'vs/platform/instantiation/common/instantiation';
import { IMarker } from 'vs/platform/markers/common/markers';
import { Event } from 'vs/base/common/event';
import { Range } from 'vs/editor/common/core/range';
export const IMarkerDecorationsService = createDecorator<IMarkerDecorationsService>('markerDecorationsService');
export interface IMarkerDecorationsService {
_serviceBrand: any;
onDidChangeMarker: Event<ITextModel>;
getMarker(model: ITextModel, decoration: IModelDecoration): IMarker | null;
}
getLiveMarkers(model: ITextModel): [Range, IMarker][];
}

View File

@@ -47,7 +47,7 @@ export interface IModeService {
getConfigurationFiles(modeId: string): URI[];
// --- instantiation
create(commaSeparatedMimetypesOrCommaSeparatedIds: string): ILanguageSelection;
create(commaSeparatedMimetypesOrCommaSeparatedIds: string | undefined): ILanguageSelection;
createByLanguageName(languageName: string): ILanguageSelection;
createByFilepathOrFirstLine(filepath: string | null, firstLine?: string): ILanguageSelection;

View File

@@ -104,7 +104,7 @@ export class ModeServiceImpl implements IModeService {
return null;
}
public getModeId(commaSeparatedMimetypesOrCommaSeparatedIds: string): string | null {
public getModeId(commaSeparatedMimetypesOrCommaSeparatedIds: string | undefined): string | null {
const modeIds = this._registry.extractModeIds(commaSeparatedMimetypesOrCommaSeparatedIds);
if (modeIds.length > 0) {
@@ -124,7 +124,7 @@ export class ModeServiceImpl implements IModeService {
// --- instantiation
public create(commaSeparatedMimetypesOrCommaSeparatedIds: string): ILanguageSelection {
public create(commaSeparatedMimetypesOrCommaSeparatedIds: string | undefined): ILanguageSelection {
return new LanguageSelection(this.onLanguagesMaybeChanged, () => {
const modeId = this.getModeId(commaSeparatedMimetypesOrCommaSeparatedIds);
return this._createModeAndGetLanguageIdentifier(modeId);

View File

@@ -73,6 +73,7 @@ class ModelData implements IDisposable {
interface IRawEditorConfig {
tabSize?: any;
indentSize?: any;
insertSpaces?: any;
detectIndentation?: any;
trimAutoWhitespace?: any;
@@ -90,9 +91,9 @@ const DEFAULT_EOL = (platform.isLinux || platform.isMacintosh) ? DefaultEndOfLin
export class ModelServiceImpl extends Disposable implements IModelService {
public _serviceBrand: any;
private _configurationService: IConfigurationService;
private _configurationServiceSubscription: IDisposable;
private _resourcePropertiesService: ITextResourcePropertiesService;
private readonly _configurationService: IConfigurationService;
private readonly _configurationServiceSubscription: IDisposable;
private readonly _resourcePropertiesService: ITextResourcePropertiesService;
private readonly _onModelAdded: Emitter<ITextModel> = this._register(new Emitter<ITextModel>());
public readonly onModelAdded: Event<ITextModel> = this._onModelAdded.event;
@@ -110,7 +111,7 @@ export class ModelServiceImpl extends Disposable implements IModelService {
/**
* All the models known in the system.
*/
private _models: { [modelId: string]: ModelData; };
private readonly _models: { [modelId: string]: ModelData; };
constructor(
@IConfigurationService configurationService: IConfigurationService,
@@ -138,6 +139,17 @@ export class ModelServiceImpl extends Disposable implements IModelService {
}
}
let indentSize = tabSize;
if (config.editor && typeof config.editor.indentSize !== 'undefined' && config.editor.indentSize !== 'tabSize') {
let parsedIndentSize = parseInt(config.editor.indentSize, 10);
if (!isNaN(parsedIndentSize)) {
indentSize = parsedIndentSize;
}
if (indentSize < 1) {
indentSize = 1;
}
}
let insertSpaces = EDITOR_MODEL_DEFAULTS.insertSpaces;
if (config.editor && typeof config.editor.insertSpaces !== 'undefined') {
insertSpaces = (config.editor.insertSpaces === 'false' ? false : Boolean(config.editor.insertSpaces));
@@ -169,6 +181,7 @@ export class ModelServiceImpl extends Disposable implements IModelService {
return {
isForSimpleWidget: isForSimpleWidget,
tabSize: tabSize,
indentSize: indentSize,
insertSpaces: insertSpaces,
detectIndentation: detectIndentation,
defaultEOL: newDefaultEOL,
@@ -210,6 +223,7 @@ export class ModelServiceImpl extends Disposable implements IModelService {
&& (currentOptions.detectIndentation === newOptions.detectIndentation)
&& (currentOptions.insertSpaces === newOptions.insertSpaces)
&& (currentOptions.tabSize === newOptions.tabSize)
&& (currentOptions.indentSize === newOptions.indentSize)
&& (currentOptions.trimAutoWhitespace === newOptions.trimAutoWhitespace)
) {
// Same indent opts, no need to touch the model
@@ -225,6 +239,7 @@ export class ModelServiceImpl extends Disposable implements IModelService {
model.updateOptions({
insertSpaces: newOptions.insertSpaces,
tabSize: newOptions.tabSize,
indentSize: newOptions.indentSize,
trimAutoWhitespace: newOptions.trimAutoWhitespace
});
}

View File

@@ -18,7 +18,7 @@ export interface ITextModelService {
* Provided a resource URI, it will return a model reference
* which should be disposed once not needed anymore.
*/
createModelReference(resource: URI): Promise<IReference<ITextEditorModel>>;
createModelReference(resource: URI): Promise<IReference<IResolvedTextEditorModel>>;
/**
* Registers a specific `scheme` content provider.
@@ -36,7 +36,7 @@ export interface ITextModelContentProvider {
/**
* Given a resource, return the content of the resource as `ITextModel`.
*/
provideTextContent(resource: URI): Promise<ITextModel> | null;
provideTextContent(resource: URI): Promise<ITextModel | undefined | null> | null | undefined;
}
export interface ITextEditorModel extends IEditorModel {
@@ -44,7 +44,15 @@ export interface ITextEditorModel extends IEditorModel {
/**
* Provides access to the underlying `ITextModel`.
*/
readonly textEditorModel: ITextModel;
readonly textEditorModel: ITextModel | null;
isReadonly(): boolean;
}
export interface IResolvedTextEditorModel extends ITextEditorModel {
/**
* Same as ITextEditorModel#textEditorModel, but never null.
*/
readonly textEditorModel: ITextModel;
}

View File

@@ -24,13 +24,13 @@ export interface ITextResourceConfigurationService {
* Fetches the value of the section for the given resource by applying language overrides.
* Value can be of native type or an object keyed off the section name.
*
* @param resource - Resource for which the configuration has to be fetched. Can be `null` or `undefined`.
* @param postion - Position in the resource for which configuration has to be fetched. Can be `null` or `undefined`.
* @param section - Section of the configuraion. Can be `null` or `undefined`.
* @param resource - Resource for which the configuration has to be fetched.
* @param postion - Position in the resource for which configuration has to be fetched.
* @param section - Section of the configuraion.
*
*/
getValue<T>(resource: URI, section?: string): T;
getValue<T>(resource: URI, position?: IPosition, section?: string): T;
getValue<T>(resource: URI | undefined, section?: string): T;
getValue<T>(resource: URI | undefined, position?: IPosition, section?: string): T;
}

View File

@@ -52,7 +52,7 @@ export interface IWebWorkerOptions {
class MonacoWebWorkerImpl<T> extends EditorWorkerClient implements MonacoWebWorker<T> {
private _foreignModuleId: string;
private readonly _foreignModuleId: string;
private _foreignModuleCreateData: any | null;
private _foreignProxy: Promise<T> | null;

View File

@@ -75,7 +75,7 @@ export class OverviewRulerZone {
export class OverviewZoneManager {
private _getVerticalOffsetForLine: (lineNumber: number) => number;
private readonly _getVerticalOffsetForLine: (lineNumber: number) => number;
private _zones: OverviewRulerZone[];
private _colorZonesInvalid: boolean;
private _lineHeight: number;
@@ -85,8 +85,8 @@ export class OverviewZoneManager {
private _pixelRatio: number;
private _lastAssignedId: number;
private _color2Id: { [color: string]: number; };
private _id2Color: string[];
private readonly _color2Id: { [color: string]: number; };
private readonly _id2Color: string[];
constructor(getVerticalOffsetForLine: (lineNumber: number) => number) {
this._getVerticalOffsetForLine = getVerticalOffsetForLine;

View File

@@ -8,8 +8,8 @@ import { ViewEventHandler } from 'vs/editor/common/viewModel/viewEventHandler';
export class ViewEventDispatcher {
private _eventHandlerGateKeeper: (callback: () => void) => void;
private _eventHandlers: ViewEventHandler[];
private readonly _eventHandlerGateKeeper: (callback: () => void) => void;
private readonly _eventHandlers: ViewEventHandler[];
private _eventQueue: ViewEvent[] | null;
private _isConsumingQueue: boolean;

View File

@@ -102,8 +102,8 @@ export class DecorationSegment {
class Stack {
public count: number;
private stopOffsets: number[];
private classNames: string[];
private readonly stopOffsets: number[];
private readonly classNames: string[];
constructor() {
this.stopOffsets = [];

View File

@@ -30,7 +30,7 @@ export class LinesLayout {
/**
* Contains whitespace information in pixels
*/
private _whitespaces: WhitespaceComputer;
private readonly _whitespaces: WhitespaceComputer;
constructor(lineCount: number, lineHeight: number) {
this._lineCount = lineCount;

View File

@@ -18,27 +18,27 @@ export class WhitespaceComputer {
/**
* heights[i] is the height in pixels for whitespace at index i
*/
private _heights: number[];
private readonly _heights: number[];
/**
* minWidths[i] is the min width in pixels for whitespace at index i
*/
private _minWidths: number[];
private readonly _minWidths: number[];
/**
* afterLineNumbers[i] is the line number whitespace at index i is after
*/
private _afterLineNumbers: number[];
private readonly _afterLineNumbers: number[];
/**
* ordinals[i] is the orinal of the whitespace at index i
*/
private _ordinals: number[];
private readonly _ordinals: number[];
/**
* prefixSum[i] = SUM(heights[j]), 1 <= j <= i
*/
private _prefixSum: number[];
private readonly _prefixSum: number[];
/**
* prefixSum[i], 1 <= i <= prefixSumValidIndex can be trusted
@@ -48,12 +48,12 @@ export class WhitespaceComputer {
/**
* ids[i] is the whitespace id of whitespace at index i
*/
private _ids: number[];
private readonly _ids: number[];
/**
* index at which a whitespace is positioned (inside heights, afterLineNumbers, prefixSum members)
*/
private _whitespaceId2Index: {
private readonly _whitespaceId2Index: {
[id: string]: number;
};

View File

@@ -56,7 +56,7 @@ class WrappingCharacterClassifier extends CharacterClassifier<CharacterClass> {
export class CharacterHardWrappingLineMapperFactory implements ILineMapperFactory {
private classifier: WrappingCharacterClassifier;
private readonly classifier: WrappingCharacterClassifier;
constructor(breakBeforeChars: string, breakAfterChars: string, breakObtrusiveChars: string) {
this.classifier = new WrappingCharacterClassifier(breakBeforeChars, breakAfterChars, breakObtrusiveChars);
@@ -255,8 +255,8 @@ export class CharacterHardWrappingLineMapperFactory implements ILineMapperFactor
export class CharacterHardWrappingLineMapping implements ILineMapping {
private _prefixSums: PrefixSumComputer;
private _wrappedLinesIndent: string;
private readonly _prefixSums: PrefixSumComputer;
private readonly _wrappedLinesIndent: string;
constructor(prefixSums: PrefixSumComputer, wrappedLinesIndent: string) {
this._prefixSums = prefixSums;

View File

@@ -32,7 +32,7 @@ export class PrefixSumComputer {
/**
* prefixSum[i], 0 <= i <= prefixSumValidIndex can be trusted
*/
private prefixSumValidIndex: Int32Array;
private readonly prefixSumValidIndex: Int32Array;
constructor(values: Uint32Array) {
this.values = values;

View File

@@ -149,7 +149,7 @@ const enum IndentGuideRepeatOption {
export class SplitLinesCollection implements IViewModelLinesCollection {
private model: ITextModel;
private readonly model: ITextModel;
private _validModelVersionId: number;
private wrappingColumn: number;
@@ -160,7 +160,7 @@ export class SplitLinesCollection implements IViewModelLinesCollection {
private prefixSumComputer: PrefixSumComputerWithCache;
private linePositionMapperFactory: ILineMapperFactory;
private readonly linePositionMapperFactory: ILineMapperFactory;
private hiddenAreasIds: string[];
@@ -1001,11 +1001,11 @@ class InvisibleIdentitySplitLine implements ISplitLine {
export class SplitLine implements ISplitLine {
private positionMapper: ILineMapping;
private outputLineCount: number;
private readonly positionMapper: ILineMapping;
private readonly outputLineCount: number;
private wrappedIndent: string;
private wrappedIndentLength: number;
private readonly wrappedIndent: string;
private readonly wrappedIndentLength: number;
private _isVisible: boolean;
constructor(positionMapper: ILineMapping, isVisible: boolean) {

View File

@@ -10,7 +10,7 @@ import { IViewLineTokens } from 'vs/editor/common/core/lineTokens';
import { IPosition, Position } from 'vs/editor/common/core/position';
import { IRange, Range } from 'vs/editor/common/core/range';
import { INewScrollPosition } from 'vs/editor/common/editorCommon';
import { EndOfLinePreference, IActiveIndentGuideInfo, IModelDecorationOptions } from 'vs/editor/common/model';
import { EndOfLinePreference, IActiveIndentGuideInfo, IModelDecorationOptions, TextModelResolvedOptions } from 'vs/editor/common/model';
import { IViewEventListener } from 'vs/editor/common/view/viewEvents';
import { IPartialViewLinesViewportData } from 'vs/editor/common/viewLayout/viewLinesViewportData';
import { IEditorWhitespace } from 'vs/editor/common/viewLayout/whitespaceComputer';
@@ -129,7 +129,7 @@ export interface IViewModel {
getCompletelyVisibleViewRange(): Range;
getCompletelyVisibleViewRangeAtScrollTop(scrollTop: number): Range;
getTabSize(): number;
getOptions(): TextModelResolvedOptions;
getLineCount(): number;
getLineContent(lineNumber: number): string;
getLineLength(lineNumber: number): number;

View File

@@ -10,7 +10,7 @@ import { IConfigurationChangedEvent } from 'vs/editor/common/config/editorOption
import { IPosition, Position } from 'vs/editor/common/core/position';
import { IRange, Range } from 'vs/editor/common/core/range';
import * as editorCommon from 'vs/editor/common/editorCommon';
import { EndOfLinePreference, IActiveIndentGuideInfo, ITextModel, TrackedRangeStickiness } from 'vs/editor/common/model';
import { EndOfLinePreference, IActiveIndentGuideInfo, ITextModel, TrackedRangeStickiness, TextModelResolvedOptions } from 'vs/editor/common/model';
import { ModelDecorationOverviewRulerOptions } from 'vs/editor/common/model/textModel';
import * as textModelEvents from 'vs/editor/common/model/textModelEvents';
import { ColorId, LanguageId, TokenizationRegistry } from 'vs/editor/common/modes';
@@ -448,10 +448,14 @@ export class ViewModel extends viewEvents.ViewEventEmitter implements IViewModel
};
}
public getTabSize(): number {
private getTabSize(): number {
return this.model.getOptions().tabSize;
}
public getOptions(): TextModelResolvedOptions {
return this.model.getOptions();
}
public getLineCount(): number {
return this.lines.getViewLineCount();
}