mirror of
https://github.com/microsoft/vscode.git
synced 2026-07-10 05:28:19 -05:00
Fixes #47004: Toggle comments shouldn't move cursor
This commit is contained in:
@@ -336,10 +336,10 @@ export class LineCommentCommand implements editorCommon.ICommand {
|
||||
}
|
||||
|
||||
return new Selection(
|
||||
result.startLineNumber,
|
||||
result.startColumn + this._deltaColumn,
|
||||
result.endLineNumber,
|
||||
result.endColumn + this._deltaColumn
|
||||
result.selectionStartLineNumber,
|
||||
result.selectionStartColumn + this._deltaColumn,
|
||||
result.positionLineNumber,
|
||||
result.positionColumn + this._deltaColumn
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -256,7 +256,7 @@ suite('Editor Contrib - Line Comment Command', () => {
|
||||
'\t!@# some text',
|
||||
'\t!@# some more text'
|
||||
],
|
||||
new Selection(1, 1, 2, 2)
|
||||
new Selection(2, 2, 1, 1)
|
||||
);
|
||||
});
|
||||
|
||||
@@ -271,7 +271,7 @@ suite('Editor Contrib - Line Comment Command', () => {
|
||||
'\t!@# some text',
|
||||
' !@# some more text'
|
||||
],
|
||||
new Selection(1, 1, 2, 2)
|
||||
new Selection(2, 2, 1, 1)
|
||||
);
|
||||
});
|
||||
|
||||
@@ -290,7 +290,7 @@ suite('Editor Contrib - Line Comment Command', () => {
|
||||
'',
|
||||
'\t!@# some more text'
|
||||
],
|
||||
new Selection(1, 1, 4, 2)
|
||||
new Selection(4, 2, 1, 1)
|
||||
);
|
||||
});
|
||||
|
||||
@@ -307,7 +307,7 @@ suite('Editor Contrib - Line Comment Command', () => {
|
||||
'\t ',
|
||||
'\t\tsome more text'
|
||||
],
|
||||
new Selection(1, 1, 3, 2)
|
||||
new Selection(3, 2, 1, 1)
|
||||
);
|
||||
});
|
||||
|
||||
@@ -324,7 +324,7 @@ suite('Editor Contrib - Line Comment Command', () => {
|
||||
'\t!@# ',
|
||||
'\t\tsome more text'
|
||||
],
|
||||
new Selection(1, 1, 3, 1)
|
||||
new Selection(3, 1, 1, 1)
|
||||
);
|
||||
});
|
||||
|
||||
@@ -369,7 +369,7 @@ suite('Editor Contrib - Line Comment Command', () => {
|
||||
'first!@#',
|
||||
'\t!@# second line'
|
||||
],
|
||||
new Selection(2, 1, 2, 7)
|
||||
new Selection(2, 7, 2, 1)
|
||||
);
|
||||
});
|
||||
|
||||
@@ -390,7 +390,7 @@ suite('Editor Contrib - Line Comment Command', () => {
|
||||
'fourth line',
|
||||
'fifth'
|
||||
],
|
||||
new Selection(1, 5, 2, 1)
|
||||
new Selection(2, 1, 1, 5)
|
||||
);
|
||||
});
|
||||
|
||||
@@ -411,7 +411,7 @@ suite('Editor Contrib - Line Comment Command', () => {
|
||||
'fourth line',
|
||||
'fifth'
|
||||
],
|
||||
new Selection(1, 5, 2, 8)
|
||||
new Selection(2, 8, 1, 5)
|
||||
);
|
||||
});
|
||||
|
||||
@@ -432,7 +432,7 @@ suite('Editor Contrib - Line Comment Command', () => {
|
||||
'!@# fourth line',
|
||||
'fifth'
|
||||
],
|
||||
new Selection(3, 5, 4, 8)
|
||||
new Selection(4, 8, 3, 5)
|
||||
);
|
||||
});
|
||||
|
||||
@@ -493,7 +493,7 @@ suite('Editor Contrib - Line Comment Command', () => {
|
||||
'fourth line',
|
||||
'fifth'
|
||||
],
|
||||
new Selection(1, 5, 2, 8)
|
||||
new Selection(2, 8, 1, 5)
|
||||
);
|
||||
|
||||
testLineCommentCommand(
|
||||
@@ -512,7 +512,7 @@ suite('Editor Contrib - Line Comment Command', () => {
|
||||
'fourth line',
|
||||
'fifth'
|
||||
],
|
||||
new Selection(1, 1, 2, 3)
|
||||
new Selection(2, 3, 1, 1)
|
||||
);
|
||||
});
|
||||
|
||||
@@ -607,6 +607,21 @@ suite('Editor Contrib - Line Comment Command', () => {
|
||||
new Selection(1, 1, 8, 60)
|
||||
);
|
||||
});
|
||||
|
||||
test('issue #47004: Toggle comments shouldn\'t move cursor', () => {
|
||||
testAddLineCommentCommand(
|
||||
[
|
||||
' A line',
|
||||
' Another line'
|
||||
],
|
||||
new Selection(2, 7, 1, 1),
|
||||
[
|
||||
' !@# A line',
|
||||
' !@# Another line'
|
||||
],
|
||||
new Selection(2, 11, 1, 1)
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
suite('Editor Contrib - Line Comment As Block Comment', () => {
|
||||
@@ -655,7 +670,7 @@ suite('Editor Contrib - Line Comment As Block Comment', () => {
|
||||
'fourth line',
|
||||
'fifth'
|
||||
],
|
||||
new Selection(1, 1, 1, 6)
|
||||
new Selection(1, 6, 1, 1)
|
||||
);
|
||||
});
|
||||
|
||||
@@ -697,7 +712,7 @@ suite('Editor Contrib - Line Comment As Block Comment', () => {
|
||||
'fourth line',
|
||||
'fifth'
|
||||
],
|
||||
new Selection(1, 5, 3, 2)
|
||||
new Selection(3, 2, 1, 5)
|
||||
);
|
||||
|
||||
testLineCommentCommand(
|
||||
@@ -716,7 +731,7 @@ suite('Editor Contrib - Line Comment As Block Comment', () => {
|
||||
'fourth line',
|
||||
'fifth'
|
||||
],
|
||||
new Selection(1, 1, 3, 11)
|
||||
new Selection(3, 11, 1, 1)
|
||||
);
|
||||
});
|
||||
});
|
||||
@@ -842,7 +857,7 @@ suite('Editor Contrib - Line Comment As Block Comment 2', () => {
|
||||
'fourth line',
|
||||
'\t\tfifth\t\t'
|
||||
],
|
||||
new Selection(5, 3, 5, 8)
|
||||
new Selection(5, 8, 5, 3)
|
||||
);
|
||||
|
||||
testLineCommentCommand(
|
||||
@@ -861,7 +876,7 @@ suite('Editor Contrib - Line Comment As Block Comment 2', () => {
|
||||
'fourth line',
|
||||
'\t\tfifth\t\t'
|
||||
],
|
||||
new Selection(5, 3, 5, 8)
|
||||
new Selection(5, 8, 5, 3)
|
||||
);
|
||||
|
||||
testLineCommentCommand(
|
||||
|
||||
Reference in New Issue
Block a user