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(/([\(\[\{])|([\)\]\}])/);
|
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;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -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();
|
||||||
|
|
|
||||||
|
|
@ -65,7 +65,7 @@ function DefaultHandlers(mouseHandler) {
|
||||||
|
|
||||||
mouseHandler.selectByLines = this.extendSelectionBy.bind(mouseHandler, "getLineRange");
|
mouseHandler.selectByLines = this.extendSelectionBy.bind(mouseHandler, "getLineRange");
|
||||||
mouseHandler.selectByWords = this.extendSelectionBy.bind(mouseHandler, "getWordRange");
|
mouseHandler.selectByWords = this.extendSelectionBy.bind(mouseHandler, "getWordRange");
|
||||||
|
|
||||||
mouseHandler.$focusWaitTimout = 250;
|
mouseHandler.$focusWaitTimout = 250;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -163,10 +163,12 @@ function DefaultHandlers(mouseHandler) {
|
||||||
|
|
||||||
if (cmpStart == -1 && cmpEnd <= 0) {
|
if (cmpStart == -1 && cmpEnd <= 0) {
|
||||||
anchor = this.$clickSelection.end;
|
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) {
|
} else if (cmpEnd == 1 && cmpStart >= 0) {
|
||||||
anchor = this.$clickSelection.start;
|
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) {
|
} else if (cmpStart == -1 && cmpEnd == 1) {
|
||||||
cursor = range.end;
|
cursor = range.end;
|
||||||
anchor = range.start;
|
anchor = range.start;
|
||||||
|
|
@ -286,7 +288,7 @@ function DefaultHandlers(mouseHandler) {
|
||||||
this.setState("select");
|
this.setState("select");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.$clickSelection = editor.selection.getWordRange(pos.row, pos.column);
|
this.$clickSelection = editor.selection.getWordRange(pos.row, pos.column);
|
||||||
this.setState("selectByWords");
|
this.setState("selectByWords");
|
||||||
};
|
};
|
||||||
|
|
@ -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) {
|
||||||
|
|
@ -345,7 +344,7 @@ function calcRangeOrientation(range, cursor) {
|
||||||
var cmp = 2 * cursor.column - range.start.column - range.end.column;
|
var cmp = 2 * cursor.column - range.start.column - range.end.column;
|
||||||
else
|
else
|
||||||
var cmp = 2 * cursor.row - range.start.row - range.end.row;
|
var cmp = 2 * cursor.row - range.start.row - range.end.row;
|
||||||
|
|
||||||
if (cmp < 0)
|
if (cmp < 0)
|
||||||
return {cursor: range.start, anchor: range.end};
|
return {cursor: range.start, anchor: range.end};
|
||||||
else
|
else
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue