mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-03-21 04:20:11 -04:00
Merge VS Code 1.23.1 (#1520)
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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)
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user