mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-16 10:58:30 -05:00
Merge from vscode 52dcb723a39ae75bee1bd56b3312d7fcdc87aeed (#6719)
This commit is contained in:
@@ -101,12 +101,13 @@ export class ReplaceCommandThatPreservesSelection implements ICommand {
|
||||
private readonly _range: Range;
|
||||
private readonly _text: string;
|
||||
private readonly _initialSelection: Selection;
|
||||
private _selectionId: string;
|
||||
private _selectionId: string | null;
|
||||
|
||||
constructor(editRange: Range, text: string, initialSelection: Selection) {
|
||||
this._range = editRange;
|
||||
this._text = text;
|
||||
this._initialSelection = initialSelection;
|
||||
this._selectionId = null;
|
||||
}
|
||||
|
||||
public getEditOperations(model: ITextModel, builder: IEditOperationBuilder): void {
|
||||
@@ -115,6 +116,6 @@ export class ReplaceCommandThatPreservesSelection implements ICommand {
|
||||
}
|
||||
|
||||
public computeCursorState(model: ITextModel, helper: ICursorStateComputerData): Selection {
|
||||
return helper.getTrackedSelection(this._selectionId);
|
||||
return helper.getTrackedSelection(this._selectionId!);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -70,13 +70,14 @@ export class ShiftCommand implements ICommand {
|
||||
|
||||
private readonly _opts: IShiftCommandOpts;
|
||||
private readonly _selection: Selection;
|
||||
private _selectionId: string;
|
||||
private _selectionId: string | null;
|
||||
private _useLastEditRangeForCursorEndPosition: boolean;
|
||||
private _selectionStartColumnStaysPut: boolean;
|
||||
|
||||
constructor(range: Selection, opts: IShiftCommandOpts) {
|
||||
this._opts = opts;
|
||||
this._selection = range;
|
||||
this._selectionId = null;
|
||||
this._useLastEditRangeForCursorEndPosition = false;
|
||||
this._selectionStartColumnStaysPut = false;
|
||||
}
|
||||
@@ -241,7 +242,7 @@ export class ShiftCommand implements ICommand {
|
||||
let lastOp = helper.getInverseEditOperations()[0];
|
||||
return new Selection(lastOp.range.endLineNumber, lastOp.range.endColumn, lastOp.range.endLineNumber, lastOp.range.endColumn);
|
||||
}
|
||||
const result = helper.getTrackedSelection(this._selectionId);
|
||||
const result = helper.getTrackedSelection(this._selectionId!);
|
||||
|
||||
if (this._selectionStartColumnStaysPut) {
|
||||
// The selection start should not move
|
||||
|
||||
@@ -13,28 +13,29 @@ import { IIdentifiedSingleEditOperation, ITextModel } from 'vs/editor/common/mod
|
||||
|
||||
export class TrimTrailingWhitespaceCommand implements ICommand {
|
||||
|
||||
private readonly selection: Selection;
|
||||
private selectionId: string;
|
||||
private readonly cursors: Position[];
|
||||
private readonly _selection: Selection;
|
||||
private _selectionId: string | null;
|
||||
private readonly _cursors: Position[];
|
||||
|
||||
constructor(selection: Selection, cursors: Position[]) {
|
||||
this.selection = selection;
|
||||
this.cursors = cursors;
|
||||
this._selection = selection;
|
||||
this._cursors = cursors;
|
||||
this._selectionId = null;
|
||||
}
|
||||
|
||||
public getEditOperations(model: ITextModel, builder: IEditOperationBuilder): void {
|
||||
let ops = trimTrailingWhitespace(model, this.cursors);
|
||||
let ops = trimTrailingWhitespace(model, this._cursors);
|
||||
for (let i = 0, len = ops.length; i < len; i++) {
|
||||
let op = ops[i];
|
||||
|
||||
builder.addEditOperation(op.range, op.text);
|
||||
}
|
||||
|
||||
this.selectionId = builder.trackSelection(this.selection);
|
||||
this._selectionId = builder.trackSelection(this._selection);
|
||||
}
|
||||
|
||||
public computeCursorState(model: ITextModel, helper: ICursorStateComputerData): Selection {
|
||||
return helper.getTrackedSelection(this.selectionId);
|
||||
return helper.getTrackedSelection(this._selectionId!);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -68,7 +68,7 @@ export abstract class CommonEditorConfiguration extends Disposable implements ed
|
||||
public readonly isSimpleWidget: boolean;
|
||||
protected _rawOptions: editorOptions.IEditorOptions;
|
||||
protected _validatedOptions: editorOptions.IValidatedEditorOptions;
|
||||
public editor: editorOptions.InternalEditorOptions;
|
||||
public editor!: editorOptions.InternalEditorOptions;
|
||||
private _isDominatedByLongLines: boolean;
|
||||
private _lineNumbersDigitCount: number;
|
||||
|
||||
@@ -268,6 +268,11 @@ const editorConfiguration: IConfigurationNode = {
|
||||
'default': 'on',
|
||||
'description': nls.localize('lineNumbers', "Controls the display of line numbers.")
|
||||
},
|
||||
'editor.cursorSurroundingLines': {
|
||||
'type': 'number',
|
||||
'default': EDITOR_DEFAULTS.viewInfo.cursorSurroundingLines,
|
||||
'description': nls.localize('cursorSurroundingLines', "Controls the minimal number of visible leading and trailing lines surrounding the cursor. Known as 'scrollOff' or `scrollOffset` in some other editors.")
|
||||
},
|
||||
'editor.renderFinalNewline': {
|
||||
'type': 'boolean',
|
||||
'default': EDITOR_DEFAULTS.viewInfo.renderFinalNewline,
|
||||
|
||||
@@ -268,6 +268,11 @@ export interface IEditorOptions {
|
||||
* Defaults to true.
|
||||
*/
|
||||
lineNumbers?: 'on' | 'off' | 'relative' | 'interval' | ((lineNumber: number) => string);
|
||||
/**
|
||||
* Controls the minimal number of visible leading and trailing lines surrounding the cursor.
|
||||
* Defaults to 0.
|
||||
*/
|
||||
cursorSurroundingLines?: number;
|
||||
/**
|
||||
* Render last line number when the file ends with a newline.
|
||||
* Defaults to true.
|
||||
@@ -988,6 +993,7 @@ export interface InternalEditorViewOptions {
|
||||
readonly ariaLabel: string;
|
||||
readonly renderLineNumbers: RenderLineNumbersType;
|
||||
readonly renderCustomLineNumbers: ((lineNumber: number) => string) | null;
|
||||
readonly cursorSurroundingLines: number;
|
||||
readonly renderFinalNewline: boolean;
|
||||
readonly selectOnLineNumbers: boolean;
|
||||
readonly glyphMargin: boolean;
|
||||
@@ -1296,6 +1302,7 @@ export class InternalEditorOptions {
|
||||
&& a.ariaLabel === b.ariaLabel
|
||||
&& a.renderLineNumbers === b.renderLineNumbers
|
||||
&& a.renderCustomLineNumbers === b.renderCustomLineNumbers
|
||||
&& a.cursorSurroundingLines === b.cursorSurroundingLines
|
||||
&& a.renderFinalNewline === b.renderFinalNewline
|
||||
&& a.selectOnLineNumbers === b.selectOnLineNumbers
|
||||
&& a.glyphMargin === b.glyphMargin
|
||||
@@ -2055,6 +2062,7 @@ export class EditorOptionsValidator {
|
||||
disableMonospaceOptimizations: disableMonospaceOptimizations,
|
||||
rulers: rulers,
|
||||
ariaLabel: _string(opts.ariaLabel, defaults.ariaLabel),
|
||||
cursorSurroundingLines: _clampedInt(opts.cursorSurroundingLines, defaults.cursorWidth, 0, Number.MAX_VALUE),
|
||||
renderLineNumbers: renderLineNumbers,
|
||||
renderCustomLineNumbers: renderCustomLineNumbers,
|
||||
renderFinalNewline: _boolean(opts.renderFinalNewline, defaults.renderFinalNewline),
|
||||
@@ -2178,6 +2186,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,
|
||||
cursorSurroundingLines: opts.viewInfo.cursorSurroundingLines,
|
||||
renderFinalNewline: opts.viewInfo.renderFinalNewline,
|
||||
selectOnLineNumbers: opts.viewInfo.selectOnLineNumbers,
|
||||
glyphMargin: opts.viewInfo.glyphMargin,
|
||||
@@ -2197,7 +2206,7 @@ export class InternalEditorOptionsFactory {
|
||||
stopRenderingLineAfter: opts.viewInfo.stopRenderingLineAfter,
|
||||
renderWhitespace: (accessibilityIsOn ? 'none' : opts.viewInfo.renderWhitespace), // DISABLED WHEN SCREEN READER IS ATTACHED
|
||||
renderControlCharacters: (accessibilityIsOn ? false : opts.viewInfo.renderControlCharacters), // DISABLED WHEN SCREEN READER IS ATTACHED
|
||||
fontLigatures: (accessibilityIsOn ? false : opts.viewInfo.fontLigatures), // DISABLED WHEN SCREEN READER IS ATTACHED
|
||||
fontLigatures: opts.viewInfo.fontLigatures,
|
||||
renderIndentGuides: (accessibilityIsOn ? false : opts.viewInfo.renderIndentGuides), // DISABLED WHEN SCREEN READER IS ATTACHED
|
||||
highlightActiveIndentGuide: opts.viewInfo.highlightActiveIndentGuide,
|
||||
renderLineHighlight: opts.viewInfo.renderLineHighlight,
|
||||
@@ -2644,6 +2653,7 @@ export const EDITOR_DEFAULTS: IValidatedEditorOptions = {
|
||||
ariaLabel: nls.localize('editorViewAccessibleLabel', "Editor content"),
|
||||
renderLineNumbers: RenderLineNumbersType.On,
|
||||
renderCustomLineNumbers: null,
|
||||
cursorSurroundingLines: 0,
|
||||
renderFinalNewline: true,
|
||||
selectOnLineNumbers: true,
|
||||
glyphMargin: true,
|
||||
|
||||
@@ -437,8 +437,6 @@ export class TypeOperations {
|
||||
return false;
|
||||
}
|
||||
|
||||
const isEqualPair = (ch === config.autoClosingPairsClose[ch]);
|
||||
|
||||
for (let i = 0, len = selections.length; i < len; i++) {
|
||||
const selection = selections[i];
|
||||
|
||||
@@ -454,14 +452,6 @@ export class TypeOperations {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (isEqualPair) {
|
||||
const lineTextBeforeCursor = lineText.substr(0, position.column - 1);
|
||||
const chCntBefore = this._countNeedlesInHaystack(lineTextBeforeCursor, ch);
|
||||
if (chCntBefore % 2 === 0) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// Must over-type a closing character typed by the editor
|
||||
let found = false;
|
||||
for (let j = 0, lenJ = autoClosedCharacters.length; j < lenJ; j++) {
|
||||
@@ -947,6 +937,7 @@ export class TypeWithAutoClosingCommand extends ReplaceCommandWithOffsetCursorSt
|
||||
super(selection, openCharacter + closeCharacter, 0, -closeCharacter.length);
|
||||
this._closeCharacter = closeCharacter;
|
||||
this.closeCharacterRange = null;
|
||||
this.enclosingRange = null;
|
||||
}
|
||||
|
||||
public computeCursorState(model: ITextModel, helper: ICursorStateComputerData): Selection {
|
||||
|
||||
@@ -11,8 +11,8 @@ import { TrackedRangeStickiness } from 'vs/editor/common/model';
|
||||
|
||||
export class OneCursor {
|
||||
|
||||
public modelState: SingleCursorState;
|
||||
public viewState: SingleCursorState;
|
||||
public modelState!: SingleCursorState;
|
||||
public viewState!: SingleCursorState;
|
||||
|
||||
private _selTrackedRange: string | null;
|
||||
private _trackSelection: boolean;
|
||||
|
||||
@@ -328,6 +328,8 @@ export class DiffComputer {
|
||||
this.modifiedLines = modifiedLines;
|
||||
this.original = new LineMarkerSequence(originalLines);
|
||||
this.modified = new LineMarkerSequence(modifiedLines);
|
||||
|
||||
this.computationStartTime = (new Date()).getTime();
|
||||
}
|
||||
|
||||
public computeDiff(): ILineChange[] {
|
||||
|
||||
@@ -7,8 +7,8 @@ import { CharCode } from 'vs/base/common/charCode';
|
||||
import { ITextBuffer } from 'vs/editor/common/model';
|
||||
|
||||
class SpacesDiffResult {
|
||||
public spacesDiff: number;
|
||||
public looksLikeAlignment: boolean;
|
||||
public spacesDiff: number = 0;
|
||||
public looksLikeAlignment: boolean = false;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -158,8 +158,19 @@ export function guessIndentation(source: ITextBuffer, defaultTabSize: number, de
|
||||
spacesDiff(previousLineText, previousLineIndentation, currentLineText, currentLineIndentation, tmp);
|
||||
|
||||
if (tmp.looksLikeAlignment) {
|
||||
// skip this line entirely
|
||||
continue;
|
||||
// if defaultInsertSpaces === true && the spaces count == tabSize, we may want to count it as valid indentation
|
||||
//
|
||||
// - item1
|
||||
// - item2
|
||||
//
|
||||
// otherwise skip this line entirely
|
||||
//
|
||||
// const a = 1,
|
||||
// b = 2;
|
||||
|
||||
if (!(defaultInsertSpaces && defaultTabSize === tmp.spacesDiff)) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
let currentSpacesDiff = tmp.spacesDiff;
|
||||
|
||||
@@ -265,16 +265,16 @@ class PieceTreeSearchCache {
|
||||
}
|
||||
|
||||
export class PieceTreeBase {
|
||||
root: TreeNode;
|
||||
protected _buffers: StringBuffer[]; // 0 is change buffer, others are readonly original buffer.
|
||||
protected _lineCnt: number;
|
||||
protected _length: number;
|
||||
protected _EOL: string;
|
||||
protected _EOLLength: number;
|
||||
protected _EOLNormalized: boolean;
|
||||
private _lastChangeBufferPos: BufferCursor;
|
||||
private _searchCache: PieceTreeSearchCache;
|
||||
private _lastVisitedLine: { lineNumber: number; value: string; };
|
||||
root!: TreeNode;
|
||||
protected _buffers!: StringBuffer[]; // 0 is change buffer, others are readonly original buffer.
|
||||
protected _lineCnt!: number;
|
||||
protected _length!: number;
|
||||
protected _EOL!: string;
|
||||
protected _EOLLength!: number;
|
||||
protected _EOLNormalized!: boolean;
|
||||
private _lastChangeBufferPos!: BufferCursor;
|
||||
private _searchCache!: PieceTreeSearchCache;
|
||||
private _lastVisitedLine!: { lineNumber: number; value: string; };
|
||||
|
||||
constructor(chunks: StringBuffer[], eol: '\r\n' | '\n', eolNormalized: boolean) {
|
||||
this.create(chunks, eol, eolNormalized);
|
||||
|
||||
@@ -329,7 +329,9 @@ export class TextModel extends Disposable implements model.ITextModel {
|
||||
|
||||
this._isTooLargeForSyncing = (bufferTextLength > TextModel.MODEL_SYNC_LIMIT);
|
||||
|
||||
this._setVersionId(1);
|
||||
this._versionId = 1;
|
||||
this._alternativeVersionId = 1;
|
||||
|
||||
this._isDisposed = false;
|
||||
this._isDisposing = false;
|
||||
|
||||
@@ -693,11 +695,7 @@ export class TextModel extends Disposable implements model.ITextModel {
|
||||
}
|
||||
|
||||
private _increaseVersionId(): void {
|
||||
this._setVersionId(this._versionId + 1);
|
||||
}
|
||||
|
||||
private _setVersionId(newVersionId: number): void {
|
||||
this._versionId = newVersionId;
|
||||
this._versionId = this._versionId + 1;
|
||||
this._alternativeVersionId = this._versionId;
|
||||
}
|
||||
|
||||
|
||||
@@ -28,7 +28,10 @@ export class TokenizationStateStore {
|
||||
private _invalidLineStartIndex: number;
|
||||
|
||||
constructor() {
|
||||
this._reset(null);
|
||||
this._beginState = [];
|
||||
this._valid = [];
|
||||
this._len = 0;
|
||||
this._invalidLineStartIndex = 0;
|
||||
}
|
||||
|
||||
private _reset(initialState: IState | null): void {
|
||||
|
||||
@@ -1288,7 +1288,7 @@ export interface CommentThread {
|
||||
threadId: string;
|
||||
resource: string | null;
|
||||
range: IRange;
|
||||
label: string;
|
||||
label: string | undefined;
|
||||
contextValue: string | undefined;
|
||||
comments: Comment[] | undefined;
|
||||
onDidChangeComments: Event<Comment[] | undefined>;
|
||||
@@ -1296,7 +1296,7 @@ export interface CommentThread {
|
||||
input?: CommentInput;
|
||||
onDidChangeInput: Event<CommentInput | undefined>;
|
||||
onDidChangeRange: Event<IRange>;
|
||||
onDidChangeLabel: Event<string>;
|
||||
onDidChangeLabel: Event<string | undefined>;
|
||||
onDidChangeCollasibleState: Event<CommentThreadCollapsibleState | undefined>;
|
||||
isDisposed: boolean;
|
||||
}
|
||||
|
||||
@@ -53,7 +53,7 @@ export class RichEditSupport {
|
||||
public readonly characterPair: CharacterPairSupport;
|
||||
public readonly wordDefinition: RegExp;
|
||||
public readonly onEnter: OnEnterSupport | null;
|
||||
public readonly indentRulesSupport: IndentRulesSupport;
|
||||
public readonly indentRulesSupport: IndentRulesSupport | null;
|
||||
public readonly indentationRules: IndentationRule | undefined;
|
||||
public readonly foldingRules: FoldingRules;
|
||||
|
||||
@@ -81,6 +81,8 @@ export class RichEditSupport {
|
||||
this.indentationRules = this._conf.indentationRules;
|
||||
if (this._conf.indentationRules) {
|
||||
this.indentRulesSupport = new IndentRulesSupport(this._conf.indentationRules);
|
||||
} else {
|
||||
this.indentRulesSupport = null;
|
||||
}
|
||||
|
||||
this.foldingRules = this._conf.folding || {};
|
||||
@@ -170,7 +172,9 @@ export class RichEditSupport {
|
||||
}
|
||||
|
||||
export class LanguageConfigurationChangeEvent {
|
||||
languageIdentifier: LanguageIdentifier;
|
||||
constructor(
|
||||
public readonly languageIdentifier: LanguageIdentifier
|
||||
) { }
|
||||
}
|
||||
|
||||
export class LanguageConfigurationRegistryImpl {
|
||||
@@ -184,11 +188,11 @@ export class LanguageConfigurationRegistryImpl {
|
||||
let previous = this._getRichEditSupport(languageIdentifier.id);
|
||||
let current = new RichEditSupport(languageIdentifier, previous, configuration);
|
||||
this._entries.set(languageIdentifier.id, current);
|
||||
this._onDidChange.fire({ languageIdentifier });
|
||||
this._onDidChange.fire(new LanguageConfigurationChangeEvent(languageIdentifier));
|
||||
return toDisposable(() => {
|
||||
if (this._entries.get(languageIdentifier.id) === current) {
|
||||
this._entries.set(languageIdentifier.id, previous);
|
||||
this._onDidChange.fire({ languageIdentifier });
|
||||
this._onDidChange.fire(new LanguageConfigurationChangeEvent(languageIdentifier));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -77,6 +77,10 @@ export function tokenizeLineToHTML(text: string, viewLineTokens: IViewLineTokens
|
||||
partContent += '​';
|
||||
break;
|
||||
|
||||
case CharCode.Space:
|
||||
partContent += ' ';
|
||||
break;
|
||||
|
||||
default:
|
||||
partContent += String.fromCharCode(charCode);
|
||||
}
|
||||
|
||||
@@ -167,6 +167,7 @@ class WorkerManager extends Disposable {
|
||||
super();
|
||||
this._modelService = modelService;
|
||||
this._editorWorkerClient = null;
|
||||
this._lastWorkerUsedTime = (new Date()).getTime();
|
||||
|
||||
let stopWorkerInterval = this._register(new IntervalTimer());
|
||||
stopWorkerInterval.cancelAndSet(() => this._checkStopIdleWorker(), Math.round(STOP_WORKER_DELTA_TIME_MS / 2));
|
||||
|
||||
@@ -16,8 +16,8 @@ export class MinimapTokensColorTracker {
|
||||
return this._INSTANCE;
|
||||
}
|
||||
|
||||
private _colors: RGBA8[];
|
||||
private _backgroundIsLight: boolean;
|
||||
private _colors!: RGBA8[];
|
||||
private _backgroundIsLight!: boolean;
|
||||
|
||||
private _onDidChange = new Emitter<void>();
|
||||
public readonly onDidChange: Event<void> = this._onDidChange.event;
|
||||
|
||||
@@ -136,6 +136,13 @@ export class CharacterHardWrappingLineMapperFactory implements ILineMapperFactor
|
||||
let charCodeIsTab = (charCode === CharCode.Tab);
|
||||
let charCodeClass = classifier.get(charCode);
|
||||
|
||||
if (strings.isLowSurrogate(charCode)/* && i + 1 < len */) {
|
||||
// A surrogate pair must always be considered as a single unit, so it is never to be broken
|
||||
// => advance visibleColumn by 1 and advance to next char code...
|
||||
visibleColumn = visibleColumn + 1;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (charCodeClass === CharacterClass.BREAK_BEFORE) {
|
||||
// This is a character that indicates that a break should happen before it
|
||||
// Since we are certain the character before `i` fits, there's no extra checking needed,
|
||||
|
||||
@@ -155,13 +155,13 @@ export class SplitLinesCollection implements IViewModelLinesCollection {
|
||||
private columnsForFullWidthChar: number;
|
||||
private wrappingIndent: WrappingIndent;
|
||||
private tabSize: number;
|
||||
private lines: ISplitLine[];
|
||||
private lines!: ISplitLine[];
|
||||
|
||||
private prefixSumComputer: PrefixSumComputerWithCache;
|
||||
private prefixSumComputer!: PrefixSumComputerWithCache;
|
||||
|
||||
private readonly linePositionMapperFactory: ILineMapperFactory;
|
||||
|
||||
private hiddenAreasIds: string[];
|
||||
private hiddenAreasIds!: string[];
|
||||
|
||||
constructor(model: ITextModel, linePositionMapperFactory: ILineMapperFactory, tabSize: number, wrappingColumn: number, columnsForFullWidthChar: number, wrappingIndent: WrappingIndent) {
|
||||
this.model = model;
|
||||
|
||||
@@ -42,7 +42,8 @@ export class ViewModelDecorations implements IDisposable {
|
||||
this._linesCollection = linesCollection;
|
||||
this._coordinatesConverter = coordinatesConverter;
|
||||
this._decorationsCache = Object.create(null);
|
||||
this._clearCachedModelDecorationsResolver();
|
||||
this._cachedModelDecorationsResolver = null;
|
||||
this._cachedModelDecorationsResolverViewRange = null;
|
||||
}
|
||||
|
||||
private _clearCachedModelDecorationsResolver(): void {
|
||||
|
||||
Reference in New Issue
Block a user