提交 53b27405 编写于 作者: A Alex Dima

Fixes #35673: Comment hotkeys throws the cursor before the comment

上级 532ffbbb
......@@ -200,8 +200,16 @@ export class LineCommentCommand implements editorCommon.ICommand {
ops = LineCommentCommand._createAddLineCommentsOperations(data.lines, s.startLineNumber);
}
const cursorPosition = new Position(s.positionLineNumber, s.positionColumn);
for (var i = 0, len = ops.length; i < len; i++) {
builder.addEditOperation(ops[i].range, ops[i].text);
if (ops[i].range.isEmpty() && ops[i].range.getStartPosition().equals(cursorPosition)) {
const lineContent = model.getLineContent(cursorPosition.lineNumber);
if (lineContent.length + 1 === cursorPosition.column) {
this._deltaColumn = ops[i].text.length;
}
}
}
this._selectionId = builder.trackSelection(s);
......
......@@ -518,6 +518,50 @@ suite('Editor Contrib - Line Comment Command', () => {
);
});
test('issue #35673: Comment hotkeys throws the cursor before the comment', () => {
testLineCommentCommand(
[
'first',
'',
'\tsecond line',
'third line',
'fourth line',
'fifth'
],
new Selection(2, 1, 2, 1),
[
'first',
'!@# ',
'\tsecond line',
'third line',
'fourth line',
'fifth'
],
new Selection(2, 5, 2, 5)
);
testLineCommentCommand(
[
'first',
'\t',
'\tsecond line',
'third line',
'fourth line',
'fifth'
],
new Selection(2, 2, 2, 2),
[
'first',
'\t!@# ',
'\tsecond line',
'third line',
'fourth line',
'fifth'
],
new Selection(2, 6, 2, 6)
);
});
test('issue #2837 "Add Line Comment" fault when blank lines involved', function () {
testAddLineCommentCommand(
[
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册