Skip to content

Commit

Permalink
Fix undesirable selection-mangling in indentLine
Browse files Browse the repository at this point in the history
Issue #1910
  • Loading branch information
marijnh committed Oct 26, 2013
1 parent ae0640c commit 759b3a0
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions lib/codemirror.js
Original file line number Diff line number Diff line change
Expand Up @@ -2759,9 +2759,7 @@ window.CodeMirror = (function() {
for (var i = Math.floor(indentation / tabSize); i; --i) {pos += tabSize; indentString += "\t";}
if (pos < indentation) indentString += spaceStr(indentation - pos);

if (indentString == curSpaceString)
setSelection(cm.doc, Pos(n, curSpaceString.length), Pos(n, curSpaceString.length));
else
if (indentString != curSpaceString || doc.sel.head.line == n && doc.sel.head.ch < curSpaceString.length)
replaceRange(cm.doc, indentString, Pos(n, 0), Pos(n, curSpaceString.length), "+input");
line.stateAfter = null;
}
Expand Down

2 comments on commit 759b3a0

@njx
Copy link

@njx njx commented on 759b3a0 Nov 1, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One minor issue with this fix is that in the case where we just want to move the selection, it still marks the document as dirty even though there's no apparent change. Would it make sense to keep the original setSelection() but just narrow the case in which we do it?

@marijnh
Copy link
Member Author

@marijnh marijnh commented on 759b3a0 Nov 3, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's a good point. Try dcf0b65

Please sign in to comment.