提交 e97e8ec6 编写于 作者: R rebornix

Fix #30181. If the tokenization has not be executed for lines above pasted...

Fix #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.
上级 9ec087df
......@@ -819,6 +819,11 @@ export interface ITokenizedModel extends ITextModel {
*/
forceTokenization(lineNumber: number): void;
/**
* Get the line number of the first line whose tokens might be inaccurate.
* @internal
*/
getFirstInvalidLineNumber(): number;
/**
* Get the tokens for the line `lineNumber`.
* The tokens might be inaccurate. Use `forceTokenization` to ensure accurate tokens.
......
......@@ -169,6 +169,10 @@ export class TextModelWithTokens extends TextModel implements editorCommon.IToke
return result;
}
public getFirstInvalidLineNumber(): number {
return this._invalidLineStartIndex + 1;
}
public forceTokenization(lineNumber: number): void {
if (lineNumber < 1 || lineNumber > this.getLineCount()) {
throw new Error('Illegal value ' + lineNumber + ' for `lineNumber`');
......
......@@ -423,6 +423,9 @@ export class AutoIndentOnPaste implements IEditorContribution {
}
const model = this.editor.getModel();
if (model.getFirstInvalidLineNumber() < range.getStartPosition().lineNumber) {
return;
}
const { tabSize, insertSpaces } = model.getOptions();
this.editor.pushUndoStop();
let textEdits: TextEdit[] = [];
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册