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

Changing Block-Comment so that it doesn't replace the whole selection #2148

Merged
merged 1 commit into from
Nov 21, 2012
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 5 additions & 6 deletions src/editor/EditorCommandHandlers.js
Original file line number Diff line number Diff line change
Expand Up @@ -332,17 +332,16 @@ define(function (require, exports, module) {
doc.batchOperation(function () {

if (canComment) {
// Get the text with the prefix and suffix added.
// Comment out - add the suffix to the start and the prefix to the end.
var completeLineSel = sel.start.ch === 0 && sel.end.ch === 0 && sel.start.line < sel.end.line;
if (completeLineSel) {
text = prefix + "\n" + editor.getSelectedText() + suffix + "\n";
doc.replaceRange(suffix + "\n", sel.end);
doc.replaceRange(prefix + "\n", sel.start);
} else {
text = prefix + editor.getSelectedText() + suffix;
doc.replaceRange(suffix, sel.end);
doc.replaceRange(prefix, sel.start);
}

// Comment out - add the suffix to the start and the prefix to the end.
doc.replaceRange(text, sel.start, sel.end);

// Correct the selection.
if (completeLineSel) {
editor.setSelection({line: sel.start.line + 1, ch: 0}, {line: sel.end.line + 1, ch: 0});
Expand Down