Cursor column is now updated if clicking the area below the text
This commit is contained in:
parent
36a7b98766
commit
b0f9097d3b
2 changed files with 8 additions and 5 deletions
|
|
@ -242,11 +242,13 @@ ace.Editor = function(renderer, doc) {
|
||||||
var pageY = ace.getDocumentY(e);
|
var pageY = ace.getDocumentY(e);
|
||||||
|
|
||||||
var pos = this.renderer.screenToTextCoordinates(pageX, pageY);
|
var pos = this.renderer.screenToTextCoordinates(pageX, pageY);
|
||||||
|
pos.row = Math.max(0, Math.min(pos.row, this.doc.getLength()-1));
|
||||||
|
|
||||||
this.moveCursorToPosition(pos);
|
this.moveCursorToPosition(pos);
|
||||||
this.selection.setSelectionAnchor(pos.row, pos.column);
|
this.selection.setSelectionAnchor(pos.row, pos.column);
|
||||||
this.renderer.scrollCursorIntoView();
|
this.renderer.scrollCursorIntoView();
|
||||||
|
|
||||||
var _self = this;
|
var self = this;
|
||||||
var mousePageX, mousePageY;
|
var mousePageX, mousePageY;
|
||||||
|
|
||||||
var onMouseSelection = function(e) {
|
var onMouseSelection = function(e) {
|
||||||
|
|
@ -262,10 +264,11 @@ ace.Editor = function(renderer, doc) {
|
||||||
if (mousePageX === undefined || mousePageY === undefined)
|
if (mousePageX === undefined || mousePageY === undefined)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
selectionLead = _self.renderer.screenToTextCoordinates(mousePageX, mousePageY);
|
selectionLead = self.renderer.screenToTextCoordinates(mousePageX, mousePageY);
|
||||||
|
selectionLead.row = Math.max(0, Math.min(selectionLead.row, self.doc.getLength()-1));
|
||||||
|
|
||||||
_self.selection.selectToPosition(selectionLead);
|
self.selection.selectToPosition(selectionLead);
|
||||||
_self.renderer.scrollCursorIntoView();
|
self.renderer.scrollCursorIntoView();
|
||||||
};
|
};
|
||||||
|
|
||||||
ace.capture(this.container, onMouseSelection, onMouseSelectionEnd);
|
ace.capture(this.container, onMouseSelection, onMouseSelectionEnd);
|
||||||
|
|
|
||||||
|
|
@ -369,7 +369,7 @@ ace.VirtualRenderer = function(container) {
|
||||||
|
|
||||||
return {
|
return {
|
||||||
row : row,
|
row : row,
|
||||||
column : this.$screenToDocumentColumn(row, col)
|
column : this.$screenToDocumentColumn(Math.max(0, Math.min(row, this.doc.getLength()-1)), col)
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue