Merge pull request #93 from brondsem/start_end_same

Don't increment both start and end points if they are the same object
This commit is contained in:
Wes Cossick 2015-09-10 17:11:38 -05:00
commit 2fd52aa629

View File

@ -399,7 +399,9 @@ function _replaceSelection(cm, active, start, end) {
cm.replaceSelection(start + text + end); cm.replaceSelection(start + text + end);
startPoint.ch += start.length; startPoint.ch += start.length;
endPoint.ch += start.length; if(startPoint !== endPoint) {
endPoint.ch += start.length;
}
} }
cm.setSelection(startPoint, endPoint); cm.setSelection(startPoint, endPoint);
cm.focus(); cm.focus();
@ -552,10 +554,14 @@ function _toggleBlock(editor, type, start_chars, end_chars) {
if(type == "bold" || type == "strikethrough") { if(type == "bold" || type == "strikethrough") {
startPoint.ch -= 2; startPoint.ch -= 2;
endPoint.ch -= 2; if(startPoint !== endPoint) {
endPoint.ch -= 2;
}
} else if(type == "italic") { } else if(type == "italic") {
startPoint.ch -= 1; startPoint.ch -= 1;
endPoint.ch -= 1; if(startPoint !== endPoint) {
endPoint.ch -= 1;
}
} }
} else { } else {
text = cm.getSelection(); text = cm.getSelection();