tweak selectByWords
This commit is contained in:
parent
38eb07df67
commit
241776dd4c
3 changed files with 12 additions and 19 deletions
|
|
@ -94,7 +94,7 @@ function BracketMatch() {
|
|||
var match = chr && chr.match(/([\(\[\{])|([\)\]\}])/);
|
||||
if (!match) {
|
||||
chr = line.charAt(pos.column);
|
||||
pos.column++;
|
||||
pos = {row: pos.row, column: pos.column + 1};
|
||||
match = chr && chr.match(/([\(\[\{])|([\)\]\}])/);
|
||||
before = false;
|
||||
}
|
||||
|
|
@ -123,9 +123,6 @@ function BracketMatch() {
|
|||
range.cursor = range.start;
|
||||
}
|
||||
|
||||
if (!before)
|
||||
pos.column--;
|
||||
|
||||
return range;
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -58,13 +58,10 @@ function GutterHandler(mouseHandler) {
|
|||
var row = e.getDocumentPosition().row;
|
||||
var selection = editor.session.selection;
|
||||
|
||||
if (e.getShiftKey()) {
|
||||
if (e.getShiftKey())
|
||||
selection.selectTo(row, 0);
|
||||
} else {
|
||||
selection.moveCursorTo(row, 0);
|
||||
selection.selectLine();
|
||||
mouseHandler.$clickSelection = selection.getRange();
|
||||
}
|
||||
else
|
||||
mouseHandler.$clickSelection = editor.selection.getLineRange(row);
|
||||
|
||||
mouseHandler.captureMouse(e, "selectByLines");
|
||||
return e.preventDefault();
|
||||
|
|
|
|||
|
|
@ -65,7 +65,7 @@ function DefaultHandlers(mouseHandler) {
|
|||
|
||||
mouseHandler.selectByLines = this.extendSelectionBy.bind(mouseHandler, "getLineRange");
|
||||
mouseHandler.selectByWords = this.extendSelectionBy.bind(mouseHandler, "getWordRange");
|
||||
|
||||
|
||||
mouseHandler.$focusWaitTimout = 250;
|
||||
}
|
||||
|
||||
|
|
@ -163,10 +163,12 @@ function DefaultHandlers(mouseHandler) {
|
|||
|
||||
if (cmpStart == -1 && cmpEnd <= 0) {
|
||||
anchor = this.$clickSelection.end;
|
||||
cursor = range.start;
|
||||
if (range.end.row != cursor.row || range.end.column != cursor.column)
|
||||
cursor = range.start;
|
||||
} else if (cmpEnd == 1 && cmpStart >= 0) {
|
||||
anchor = this.$clickSelection.start;
|
||||
cursor = range.end;
|
||||
if (range.start.row != cursor.row || range.start.column != cursor.column)
|
||||
cursor = range.end;
|
||||
} else if (cmpStart == -1 && cmpEnd == 1) {
|
||||
cursor = range.end;
|
||||
anchor = range.start;
|
||||
|
|
@ -286,7 +288,7 @@ function DefaultHandlers(mouseHandler) {
|
|||
this.setState("select");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
this.$clickSelection = editor.selection.getWordRange(pos.row, pos.column);
|
||||
this.setState("selectByWords");
|
||||
};
|
||||
|
|
@ -296,10 +298,7 @@ function DefaultHandlers(mouseHandler) {
|
|||
var editor = this.editor;
|
||||
|
||||
this.setState("selectByLines");
|
||||
|
||||
editor.moveCursorToPosition(pos);
|
||||
editor.selection.selectLine();
|
||||
this.$clickSelection = editor.getSelectionRange();
|
||||
this.$clickSelection = editor.selection.getLineRange(pos.row);
|
||||
};
|
||||
|
||||
this.onQuadClick = function(ev) {
|
||||
|
|
@ -345,7 +344,7 @@ function calcRangeOrientation(range, cursor) {
|
|||
var cmp = 2 * cursor.column - range.start.column - range.end.column;
|
||||
else
|
||||
var cmp = 2 * cursor.row - range.start.row - range.end.row;
|
||||
|
||||
|
||||
if (cmp < 0)
|
||||
return {cursor: range.start, anchor: range.end};
|
||||
else
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue