Skip to content

Commit

Permalink
Fix #38833. Avoid pasted area indent adjustment.
Browse files Browse the repository at this point in the history
  • Loading branch information
rebornix committed Nov 28, 2017
1 parent 58c1273 commit e77b196
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/vs/editor/contrib/indentation/indentation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import { ShiftCommand } from 'vs/editor/common/commands/shiftCommand';
import { TextEdit, StandardTokenType } from 'vs/editor/common/modes';
import * as IndentUtil from './indentUtils';
import { ICodeEditor } from 'vs/editor/browser/editorBrowser';
import { IndentConsts } from 'vs/editor/common/modes/supports/indentRules';

export function shiftIndent(tabSize: number, indentation: string, count?: number): string {
count = count || 1;
Expand Down Expand Up @@ -472,6 +473,16 @@ export class AutoIndentOnPaste implements IEditorContribution {
text: newIndent
});
firstLineText = newIndent + firstLineText.substr(oldIndentation.length);
} else {
let indentMetadata = LanguageConfigurationRegistry.getIndentMetadata(model, startLineNumber);

if (indentMetadata === 0 || indentMetadata === IndentConsts.UNINDENT_MASK) {
// we paste content into a line where only contains whitespaces
// after pasting, the indentation of the first line is already correct
// the first line doesn't match any indentation rule
// then no-op.
return;
}
}
}
}
Expand Down

0 comments on commit e77b196

Please sign in to comment.