Merge VS Code 1.23.1 (#1520)

This commit is contained in:
Matt Irvine
2018-06-05 11:24:51 -07:00
committed by GitHub
parent e3baf5c443
commit 0c58f09e59
3651 changed files with 74249 additions and 48599 deletions

View File

@@ -225,7 +225,7 @@ export class ChangeIndentationSizeAction extends EditorAction {
return undefined;
}
let creationOpts = modelService.getCreationOptions(model.getLanguageIdentifier().language, model.uri);
let creationOpts = modelService.getCreationOptions(model.getLanguageIdentifier().language, model.uri, model.isForSimpleWidget);
const picks = [1, 2, 3, 4, 5, 6, 7, 8].map(n => ({
id: n.toString(),
label: n.toString(),
@@ -298,7 +298,7 @@ export class DetectIndentation extends EditorAction {
return;
}
let creationOpts = modelService.getCreationOptions(model.getLanguageIdentifier().language, model.uri);
let creationOpts = modelService.getCreationOptions(model.getLanguageIdentifier().language, model.uri, model.isForSimpleWidget);
model.detectIndentation(creationOpts.insertSpaces, creationOpts.tabSize);
}
}
@@ -586,18 +586,27 @@ function getIndentationEditOperations(model: ITextModel, builder: IEditOperation
spaces += ' ';
}
const content = model.getLinesContent();
for (let i = 0; i < content.length; i++) {
let lastIndentationColumn = model.getLineFirstNonWhitespaceColumn(i + 1);
let spacesRegExp = new RegExp(spaces, 'gi');
for (let lineNumber = 1, lineCount = model.getLineCount(); lineNumber <= lineCount; lineNumber++) {
let lastIndentationColumn = model.getLineFirstNonWhitespaceColumn(lineNumber);
if (lastIndentationColumn === 0) {
lastIndentationColumn = model.getLineMaxColumn(i + 1);
lastIndentationColumn = model.getLineMaxColumn(lineNumber);
}
const text = (tabsToSpaces ? content[i].substr(0, lastIndentationColumn).replace(/\t/ig, spaces) :
content[i].substr(0, lastIndentationColumn).replace(new RegExp(spaces, 'gi'), '\t')) +
content[i].substr(lastIndentationColumn);
if (lastIndentationColumn === 1) {
continue;
}
builder.addEditOperation(new Range(i + 1, 1, i + 1, model.getLineMaxColumn(i + 1)), text);
const originalIndentationRange = new Range(lineNumber, 1, lineNumber, lastIndentationColumn);
const originalIndentation = model.getValueInRange(originalIndentationRange);
const newIndentation = (
tabsToSpaces
? originalIndentation.replace(/\t/ig, spaces)
: originalIndentation.replace(spacesRegExp, '\t')
);
builder.addEditOperation(originalIndentationRange, newIndentation);
}
}

View File

@@ -57,7 +57,7 @@ suite('Editor Contrib - Indentation to Spaces', () => {
'fourth line',
'fifth'
],
new Selection(1, 5, 1, 5)
new Selection(1, 9, 1, 9)
);
});
@@ -79,7 +79,7 @@ suite('Editor Contrib - Indentation to Spaces', () => {
' fourth line',
'fifth'
],
new Selection(1, 5, 1, 5)
new Selection(1, 7, 1, 7)
);
});
@@ -157,7 +157,7 @@ suite('Editor Contrib - Indentation to Tabs', () => {
' fourth line',
'fifth'
],
new Selection(1, 5, 1, 5),
new Selection(1, 8, 1, 8),
2,
[
'\t\t\tfirst ',
@@ -169,4 +169,18 @@ suite('Editor Contrib - Indentation to Tabs', () => {
new Selection(1, 5, 1, 5)
);
});
test('issue #45996', function () {
testIndentationToSpacesCommand(
[
'\tabc',
],
new Selection(1, 3, 1, 3),
4,
[
' abc',
],
new Selection(1, 6, 1, 6)
);
});
});