Skip to content

Commit e97e8ec

Browse files
committed
Fix microsoft#30181. If the tokenization has not be executed for lines above pasted area, we do not force tokenization info as we do not wait for the tokenization to complete.
1 parent 9ec087d commit e97e8ec

3 files changed

Lines changed: 12 additions & 0 deletions

File tree

src/vs/editor/common/editorCommon.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -819,6 +819,11 @@ export interface ITokenizedModel extends ITextModel {
819819
*/
820820
forceTokenization(lineNumber: number): void;
821821

822+
/**
823+
* Get the line number of the first line whose tokens might be inaccurate.
824+
* @internal
825+
*/
826+
getFirstInvalidLineNumber(): number;
822827
/**
823828
* Get the tokens for the line `lineNumber`.
824829
* The tokens might be inaccurate. Use `forceTokenization` to ensure accurate tokens.

src/vs/editor/common/model/textModelWithTokens.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,10 @@ export class TextModelWithTokens extends TextModel implements editorCommon.IToke
169169
return result;
170170
}
171171

172+
public getFirstInvalidLineNumber(): number {
173+
return this._invalidLineStartIndex + 1;
174+
}
175+
172176
public forceTokenization(lineNumber: number): void {
173177
if (lineNumber < 1 || lineNumber > this.getLineCount()) {
174178
throw new Error('Illegal value ' + lineNumber + ' for `lineNumber`');

src/vs/editor/contrib/indentation/common/indentation.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -423,6 +423,9 @@ export class AutoIndentOnPaste implements IEditorContribution {
423423
}
424424

425425
const model = this.editor.getModel();
426+
if (model.getFirstInvalidLineNumber() < range.getStartPosition().lineNumber) {
427+
return;
428+
}
426429
const { tabSize, insertSpaces } = model.getOptions();
427430
this.editor.pushUndoStop();
428431
let textEdits: TextEdit[] = [];

0 commit comments

Comments
 (0)