Skip to content

Commit 791f59f

Browse files
committed
Fix microsoft#32508. Tokenize tokens when cheap
1 parent f90f8ae commit 791f59f

1 file changed

Lines changed: 7 additions & 4 deletions

File tree

src/vs/editor/contrib/linesOperations/common/moveLinesCommand.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ export class MoveLinesCommand implements ICommand {
9898

9999
let insertingText = movingLineText;
100100

101-
if (this.isAutoIndent(model, s)) {
101+
if (this.shouldAutoIndent(model, s)) {
102102
let movingLineMatchResult = this.matchEnterRule(model, indentConverter, tabSize, movingLineNumber, s.startLineNumber - 1);
103103
// if s.startLineNumber - 1 matches onEnter rule, we still honor that.
104104
if (movingLineMatchResult !== null) {
@@ -178,7 +178,7 @@ export class MoveLinesCommand implements ICommand {
178178
// Insert line that needs to be moved after
179179
builder.addEditOperation(new Range(s.endLineNumber, model.getLineMaxColumn(s.endLineNumber), s.endLineNumber, model.getLineMaxColumn(s.endLineNumber)), '\n' + movingLineText);
180180

181-
if (this.isAutoIndent(model, s)) {
181+
if (this.shouldAutoIndent(model, s)) {
182182
virtualModel.getLineContent = (lineNumber: number) => {
183183
if (lineNumber === movingLineNumber) {
184184
return model.getLineContent(s.startLineNumber);
@@ -261,7 +261,6 @@ export class MoveLinesCommand implements ICommand {
261261
}
262262

263263
let maxColumn = model.getLineMaxColumn(validPrecedingLine);
264-
// TODO@Peng TODO@forceTokenization: getEnterAction forces tokenization
265264
let enter = LanguageConfigurationRegistry.getEnterAction(model, new Range(validPrecedingLine, maxColumn, validPrecedingLine, maxColumn));
266265

267266
if (enter) {
@@ -298,10 +297,14 @@ export class MoveLinesCommand implements ICommand {
298297
return str.replace(/^\s+/, '');
299298
}
300299

301-
private isAutoIndent(model: ITokenizedModel, selection: Selection) {
300+
private shouldAutoIndent(model: ITokenizedModel, selection: Selection) {
302301
if (!this._autoIndent) {
303302
return false;
304303
}
304+
// if it's not easy to tokenize, we stop auto indent.
305+
if (!model.isCheapToTokenize(selection.startLineNumber)) {
306+
return false;
307+
}
305308
let languageAtSelectionStart = model.getLanguageIdAtPosition(selection.startLineNumber, 1);
306309
let languageAtSelectionEnd = model.getLanguageIdAtPosition(selection.endLineNumber, 1);
307310

0 commit comments

Comments
 (0)