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];
|
||||
|
||||
// Need to do some clamping action here.
|
||||
if (this.$useWrapMode) {
|
||||
if (docColumn >= column) {
|
||||
// We remove one character at the end such that the docColumn
|
||||
// position returned is not associated to the next row on the
|
||||
// screen.
|
||||
docColumn = column - 1;
|
||||
}
|
||||
} else {
|
||||
docColumn = Math.min(docColumn, line.length);
|
||||
// We remove one character at the end so that the docColumn
|
||||
// position returned is not associated to the next row on the screen.
|
||||
if (this.$useWrapMode && docColumn >= column) {
|
||||
docColumn = column - 1;
|
||||
}
|
||||
|
||||
if (foldLine) {
|
||||
|
|
|
|||
|
|
@ -169,7 +169,6 @@ function DefaultHandlers(editor) {
|
|||
if (distance > DRAG_OFFSET) {
|
||||
state = STATE_SELECT;
|
||||
var cursor = editor.renderer.screenToTextCoordinates(mousePageX, mousePageY);
|
||||
cursor.row = Math.max(0, Math.min(cursor.row, editor.session.getLength()-1));
|
||||
onStartSelect(cursor);
|
||||
}
|
||||
else if ((time - mousedownTime) > editor.getDragDelay()) {
|
||||
|
|
@ -205,7 +204,6 @@ function DefaultHandlers(editor) {
|
|||
var onUpdateSelectionInterval = function() {
|
||||
var anchor;
|
||||
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.contains(cursor.row, cursor.column)) {
|
||||
|
|
@ -231,8 +229,6 @@ function DefaultHandlers(editor) {
|
|||
|
||||
var onDragSelectionInterval = function() {
|
||||
dragCursor = editor.renderer.screenToTextCoordinates(mousePageX, mousePageY);
|
||||
dragCursor.row = Math.max(0, Math.min(dragCursor.row, editor.session.getLength() - 1));
|
||||
|
||||
editor.moveCursorToPosition(dragCursor);
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -90,7 +90,6 @@ var MouseEvent = exports.MouseEvent = function(domEvent, editor) {
|
|||
var pageX = event.getDocumentX(this.domEvent);
|
||||
var pageY = event.getDocumentY(this.domEvent);
|
||||
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;
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue