提交 0f384352 编写于 作者: A Alex Dima

Fixes #4312: pressing Tab when a selection is inside a line replaces the selection with a \t

上级 1a37bd04
......@@ -1541,6 +1541,14 @@ export class OneCursorOp {
ctx.executeCommand = new ReplaceCommand(selection, typeText);
return true;
} else {
if (selection.startLineNumber === selection.endLineNumber) {
let lineMaxColumn = cursor.model.getLineMaxColumn(selection.startLineNumber);
if (selection.startColumn !== 1 || selection.endColumn !== lineMaxColumn) {
// This is a single line selection that is not the entire line
ctx.executeCommand = new ReplaceCommand(selection, '\t');
return true;
}
}
return this.indent(cursor, ctx);
}
}
......
......@@ -1465,6 +1465,21 @@ suite('Editor Controller - Regression tests', () => {
});
});
test('issue #4312: trying to type a tab character over a sequence of spaces results in unexpected behaviour', () => {
usingCursor({
text: [
'var foo = 123; // this is a comment'
'var bar = 4; // another comment'
],
modelOpts: { insertSpaces: false, tabSize: 4, detectIndentation: false, defaultEOL: DefaultEndOfLine.LF, trimAutoWhitespace: true }
}, (model, cursor) => {
moveTo(cursor, 1, 15, false);
moveTo(cursor, 1, 22, true);
cursorCommand(cursor, H.Tab);
assert.equal(model.getLineContent(1), 'var foo = 123;\t// this is a comment');
});
});
test('issue #832: deleteWordLeft', () => {
usingCursor({
text: [
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册