remove redundant clamping while converting between screen and document positions
This commit is contained in:
parent
6381f3e048
commit
1e4828e3d8
3 changed files with 4 additions and 15 deletions
|
|
@ -1502,16 +1502,10 @@ var EditSession = function(text, mode) {
|
||||||
|
|
||||||
docColumn += this.$getStringScreenWidth(line, screenColumn)[1];
|
docColumn += this.$getStringScreenWidth(line, screenColumn)[1];
|
||||||
|
|
||||||
// Need to do some clamping action here.
|
// We remove one character at the end so that the docColumn
|
||||||
if (this.$useWrapMode) {
|
// position returned is not associated to the next row on the screen.
|
||||||
if (docColumn >= column) {
|
if (this.$useWrapMode && docColumn >= column) {
|
||||||
// We remove one character at the end such that the docColumn
|
docColumn = column - 1;
|
||||||
// position returned is not associated to the next row on the
|
|
||||||
// screen.
|
|
||||||
docColumn = column - 1;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
docColumn = Math.min(docColumn, line.length);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (foldLine) {
|
if (foldLine) {
|
||||||
|
|
|
||||||
|
|
@ -169,7 +169,6 @@ function DefaultHandlers(editor) {
|
||||||
if (distance > DRAG_OFFSET) {
|
if (distance > DRAG_OFFSET) {
|
||||||
state = STATE_SELECT;
|
state = STATE_SELECT;
|
||||||
var cursor = editor.renderer.screenToTextCoordinates(mousePageX, mousePageY);
|
var cursor = editor.renderer.screenToTextCoordinates(mousePageX, mousePageY);
|
||||||
cursor.row = Math.max(0, Math.min(cursor.row, editor.session.getLength()-1));
|
|
||||||
onStartSelect(cursor);
|
onStartSelect(cursor);
|
||||||
}
|
}
|
||||||
else if ((time - mousedownTime) > editor.getDragDelay()) {
|
else if ((time - mousedownTime) > editor.getDragDelay()) {
|
||||||
|
|
@ -205,7 +204,6 @@ function DefaultHandlers(editor) {
|
||||||
var onUpdateSelectionInterval = function() {
|
var onUpdateSelectionInterval = function() {
|
||||||
var anchor;
|
var anchor;
|
||||||
var cursor = editor.renderer.screenToTextCoordinates(mousePageX, mousePageY);
|
var cursor = editor.renderer.screenToTextCoordinates(mousePageX, mousePageY);
|
||||||
cursor.row = Math.max(0, Math.min(cursor.row, editor.session.getLength()-1));
|
|
||||||
|
|
||||||
if (_self.$clickSelection) {
|
if (_self.$clickSelection) {
|
||||||
if (_self.$clickSelection.contains(cursor.row, cursor.column)) {
|
if (_self.$clickSelection.contains(cursor.row, cursor.column)) {
|
||||||
|
|
@ -231,8 +229,6 @@ function DefaultHandlers(editor) {
|
||||||
|
|
||||||
var onDragSelectionInterval = function() {
|
var onDragSelectionInterval = function() {
|
||||||
dragCursor = editor.renderer.screenToTextCoordinates(mousePageX, mousePageY);
|
dragCursor = editor.renderer.screenToTextCoordinates(mousePageX, mousePageY);
|
||||||
dragCursor.row = Math.max(0, Math.min(dragCursor.row, editor.session.getLength() - 1));
|
|
||||||
|
|
||||||
editor.moveCursorToPosition(dragCursor);
|
editor.moveCursorToPosition(dragCursor);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -90,7 +90,6 @@ var MouseEvent = exports.MouseEvent = function(domEvent, editor) {
|
||||||
var pageX = event.getDocumentX(this.domEvent);
|
var pageX = event.getDocumentX(this.domEvent);
|
||||||
var pageY = event.getDocumentY(this.domEvent);
|
var pageY = event.getDocumentY(this.domEvent);
|
||||||
this.$pos = this.editor.renderer.screenToTextCoordinates(pageX, pageY);
|
this.$pos = this.editor.renderer.screenToTextCoordinates(pageX, pageY);
|
||||||
this.$pos.row = Math.max(0, Math.min(this.$pos.row, this.editor.session.getLength()-1));
|
|
||||||
return this.$pos;
|
return this.$pos;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue