diff --git a/src/vs/editor/common/modes.ts b/src/vs/editor/common/modes.ts index 2b5eeb7623a375ab1252baf8c276be857ced1259..bb1af92f90dd6d7fb3547fd30866dc34b95d3398 100644 --- a/src/vs/editor/common/modes.ts +++ b/src/vs/editor/common/modes.ts @@ -876,7 +876,7 @@ export interface DocumentSymbolProvider { provideDocumentSymbols(model: model.ITextModel, token: CancellationToken): ProviderResult; } -export type TextEdit = { range: IRange; text: string; eol?: model.EndOfLineSequence; } | { range: undefined; text: undefined; eol: model.EndOfLineSequence; }; +export type TextEdit = { range: IRange; text: string; eol?: model.EndOfLineSequence; }; /** * Interface used to format a model diff --git a/src/vs/editor/common/services/editorSimpleWorker.ts b/src/vs/editor/common/services/editorSimpleWorker.ts index 84590d69acecc4fd6ebc0232932ed14d1f509ed7..ed3a564f52e7ff64f08d60d0a4035229dcf61288 100644 --- a/src/vs/editor/common/services/editorSimpleWorker.ts +++ b/src/vs/editor/common/services/editorSimpleWorker.ts @@ -425,8 +425,8 @@ export abstract class BaseEditorSimpleWorker { lastEol = eol; } - if (!range) { - // eol-change only + if (Range.isEmpty(range) && !text) { + // empty change continue; } @@ -463,7 +463,7 @@ export abstract class BaseEditorSimpleWorker { } if (typeof lastEol === 'number') { - result.push({ eol: lastEol, text: undefined, range: undefined }); + result.push({ eol: lastEol, text: '', range: { startLineNumber: 0, startColumn: 0, endLineNumber: 0, endColumn: 0 } }); } return Promise.resolve(result); diff --git a/src/vs/monaco.d.ts b/src/vs/monaco.d.ts index 54a6804c68de20ddc4cdee4c4d22f9bbc99e3fd5..d6ea545dd8570d03e51802148bcd89d84008f833 100644 --- a/src/vs/monaco.d.ts +++ b/src/vs/monaco.d.ts @@ -5148,10 +5148,6 @@ declare namespace monaco.languages { range: IRange; text: string; eol?: editor.EndOfLineSequence; - } | { - range: undefined; - text: undefined; - eol: editor.EndOfLineSequence; }; /** diff --git a/src/vs/workbench/api/node/extHostTypes.ts b/src/vs/workbench/api/node/extHostTypes.ts index f2a25b2a55463f657e83b3272527c5d859bba0de..87e5be63ef8dca61a210c8040636f1230aec7cbe 100644 --- a/src/vs/workbench/api/node/extHostTypes.ts +++ b/src/vs/workbench/api/node/extHostTypes.ts @@ -447,7 +447,7 @@ export class TextEdit { } static setEndOfLine(eol: EndOfLine): TextEdit { - let ret = new TextEdit(undefined, undefined); + let ret = new TextEdit(new Range(new Position(0, 0), new Position(0, 0)), ''); ret.newEol = eol; return ret; } @@ -513,8 +513,8 @@ export interface IFileOperationOptions { export interface IFileOperation { _type: 1; - from: URI; - to: URI; + from?: URI; + to?: URI; options?: IFileOperationOptions; } @@ -567,7 +567,7 @@ export class WorkspaceEdit implements vscode.WorkspaceEdit { for (let i = 0; i < this._edits.length; i++) { const element = this._edits[i]; if (element._type === 2 && element.uri.toString() === uri.toString()) { - this._edits[i] = undefined; + this._edits[i] = undefined!; // will be coalesced down below } } this._edits = coalesce(this._edits); @@ -606,8 +606,8 @@ export class WorkspaceEdit implements vscode.WorkspaceEdit { return values(textEdits); } - _allEntries(): ([URI, TextEdit[]] | [URI, URI, IFileOperationOptions])[] { - let res: ([URI, TextEdit[]] | [URI, URI, IFileOperationOptions])[] = []; + _allEntries(): ([URI, TextEdit[]] | [URI?, URI?, IFileOperationOptions?])[] { + let res: ([URI, TextEdit[]] | [URI?, URI?, IFileOperationOptions?])[] = []; for (let edit of this._edits) { if (edit._type === 1) { res.push([edit.from, edit.to, edit.options]); @@ -938,7 +938,7 @@ export class SymbolInformation { if (locationOrUri instanceof Location) { this.location = locationOrUri; } else if (rangeOrContainer instanceof Range) { - this.location = new Location(locationOrUri, rangeOrContainer); + this.location = new Location(locationOrUri!, rangeOrContainer); } SymbolInformation.validate(this); diff --git a/src/vs/workbench/test/electron-browser/api/extHostTypes.test.ts b/src/vs/workbench/test/electron-browser/api/extHostTypes.test.ts index 80ddda65980da6f619595dad745f62ae69107dfd..6e121e81c92282af6b9a53fafcba3dbc9a649e24 100644 --- a/src/vs/workbench/test/electron-browser/api/extHostTypes.test.ts +++ b/src/vs/workbench/test/electron-browser/api/extHostTypes.test.ts @@ -384,12 +384,12 @@ suite('ExtHostTypes', function () { const all = edit._allEntries(); assert.equal(all.length, 4); - function isFileChange(thing: [URI, types.TextEdit[]] | [URI, URI, { overwrite?: boolean }]): thing is [URI, URI, { overwrite?: boolean }] { + function isFileChange(thing: [URI, types.TextEdit[]] | [URI?, URI?, { overwrite?: boolean }?]): thing is [URI?, URI?, { overwrite?: boolean }?] { const [f, s] = thing; return URI.isUri(f) && URI.isUri(s); } - function isTextChange(thing: [URI, types.TextEdit[]] | [URI, URI, { overwrite?: boolean }]): thing is [URI, types.TextEdit[]] { + function isTextChange(thing: [URI, types.TextEdit[]] | [URI?, URI?, { overwrite?: boolean }?]): thing is [URI, types.TextEdit[]] { const [f, s] = thing; return URI.isUri(f) && Array.isArray(s); }