This commit is contained in:
Alex Dima 2019-09-13 15:50:15 +02:00
parent 85e410a0fb
commit 8c9b9589cf
3 changed files with 25 additions and 3 deletions

View File

@ -179,7 +179,7 @@ export class ShiftCommand implements ICommand {
}
this._addEditOperation(builder, new Range(lineNumber, 1, lineNumber, indentationEndIndex + 1), desiredIndent);
if (lineNumber === startLine) {
if (lineNumber === startLine && !this._selection.isEmpty()) {
// Force the startColumn to stay put because we're inserting after it
this._selectionStartColumnStaysPut = (this._selection.startColumn <= indentationEndIndex + 1);
}
@ -226,7 +226,7 @@ export class ShiftCommand implements ICommand {
this._addEditOperation(builder, new Range(lineNumber, 1, lineNumber, indentationEndIndex + 1), '');
} else {
this._addEditOperation(builder, new Range(lineNumber, 1, lineNumber, 1), oneIndent);
if (lineNumber === startLine) {
if (lineNumber === startLine && !this._selection.isEmpty()) {
// Force the startColumn to stay put because we're inserting after it
this._selectionStartColumnStaysPut = (this._selection.startColumn === 1);
}

View File

@ -928,6 +928,28 @@ suite('Editor Contrib - Line Operations', () => {
model.dispose();
});
test('issue #80736: Indenting while the cursor is at the start of a line of text causes the added spaces or tab to be selected', () => {
const model = createTextModel(
[
'Some text'
].join('\n'),
{
insertSpaces: false,
}
);
withTestCodeEditor(null, { model: model }, (editor) => {
const indentLinesAction = new IndentLinesAction();
editor.setPosition(new Position(1, 1));
indentLinesAction.run(null!, editor);
assert.equal(model.getLineContent(1), '\tSome text');
assert.deepEqual(editor.getSelection(), new Selection(1, 2, 1, 2));
});
model.dispose();
});
test('issue #62112: Delete line does not work properly when multiple cursors are on line', () => {
const TEXT = [
'a',

View File

@ -92,7 +92,7 @@ suite('Editor Commands - ShiftCommand', () => {
'',
'123'
],
new Selection(1, 1, 1, 2)
new Selection(1, 2, 1, 2)
);
});