tweak selectByWords

This commit is contained in:
nightwing 2012-06-16 17:07:55 +04:00
commit 241776dd4c
3 changed files with 12 additions and 19 deletions

View file

@ -94,7 +94,7 @@ function BracketMatch() {
var match = chr && chr.match(/([\(\[\{])|([\)\]\}])/); var match = chr && chr.match(/([\(\[\{])|([\)\]\}])/);
if (!match) { if (!match) {
chr = line.charAt(pos.column); chr = line.charAt(pos.column);
pos.column++; pos = {row: pos.row, column: pos.column + 1};
match = chr && chr.match(/([\(\[\{])|([\)\]\}])/); match = chr && chr.match(/([\(\[\{])|([\)\]\}])/);
before = false; before = false;
} }
@ -123,9 +123,6 @@ function BracketMatch() {
range.cursor = range.start; range.cursor = range.start;
} }
if (!before)
pos.column--;
return range; return range;
}; };

View file

@ -58,13 +58,10 @@ function GutterHandler(mouseHandler) {
var row = e.getDocumentPosition().row; var row = e.getDocumentPosition().row;
var selection = editor.session.selection; var selection = editor.session.selection;
if (e.getShiftKey()) { if (e.getShiftKey())
selection.selectTo(row, 0); selection.selectTo(row, 0);
} else { else
selection.moveCursorTo(row, 0); mouseHandler.$clickSelection = editor.selection.getLineRange(row);
selection.selectLine();
mouseHandler.$clickSelection = selection.getRange();
}
mouseHandler.captureMouse(e, "selectByLines"); mouseHandler.captureMouse(e, "selectByLines");
return e.preventDefault(); return e.preventDefault();

View file

@ -163,9 +163,11 @@ function DefaultHandlers(mouseHandler) {
if (cmpStart == -1 && cmpEnd <= 0) { if (cmpStart == -1 && cmpEnd <= 0) {
anchor = this.$clickSelection.end; anchor = this.$clickSelection.end;
if (range.end.row != cursor.row || range.end.column != cursor.column)
cursor = range.start; cursor = range.start;
} else if (cmpEnd == 1 && cmpStart >= 0) { } else if (cmpEnd == 1 && cmpStart >= 0) {
anchor = this.$clickSelection.start; anchor = this.$clickSelection.start;
if (range.start.row != cursor.row || range.start.column != cursor.column)
cursor = range.end; cursor = range.end;
} else if (cmpStart == -1 && cmpEnd == 1) { } else if (cmpStart == -1 && cmpEnd == 1) {
cursor = range.end; cursor = range.end;
@ -296,10 +298,7 @@ function DefaultHandlers(mouseHandler) {
var editor = this.editor; var editor = this.editor;
this.setState("selectByLines"); this.setState("selectByLines");
this.$clickSelection = editor.selection.getLineRange(pos.row);
editor.moveCursorToPosition(pos);
editor.selection.selectLine();
this.$clickSelection = editor.getSelectionRange();
}; };
this.onQuadClick = function(ev) { this.onQuadClick = function(ev) {