Skip to content
This repository was archived by the owner on Sep 6, 2021. It is now read-only.

Commit 2950894

Browse files
committed
Merge pull request #2148 from TomMalbran/tom/fix-block-comment-replace
Changing Block-Comment so that it inserts text at start & end instead of replacing the whole selected range.
2 parents d75bf70 + 0af8400 commit 2950894

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

src/editor/EditorCommandHandlers.js

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -332,17 +332,16 @@ define(function (require, exports, module) {
332332
doc.batchOperation(function () {
333333

334334
if (canComment) {
335-
// Get the text with the prefix and suffix added.
335+
// Comment out - add the suffix to the start and the prefix to the end.
336336
var completeLineSel = sel.start.ch === 0 && sel.end.ch === 0 && sel.start.line < sel.end.line;
337337
if (completeLineSel) {
338-
text = prefix + "\n" + editor.getSelectedText() + suffix + "\n";
338+
doc.replaceRange(suffix + "\n", sel.end);
339+
doc.replaceRange(prefix + "\n", sel.start);
339340
} else {
340-
text = prefix + editor.getSelectedText() + suffix;
341+
doc.replaceRange(suffix, sel.end);
342+
doc.replaceRange(prefix, sel.start);
341343
}
342344

343-
// Comment out - add the suffix to the start and the prefix to the end.
344-
doc.replaceRange(text, sel.start, sel.end);
345-
346345
// Correct the selection.
347346
if (completeLineSel) {
348347
editor.setSelection({line: sel.start.line + 1, ch: 0}, {line: sel.end.line + 1, ch: 0});

0 commit comments

Comments
 (0)