the cursor works always in document space
This commit is contained in:
parent
3d8d834aec
commit
7d62c76128
2 changed files with 1 additions and 9 deletions
|
|
@ -259,14 +259,6 @@ var Document = function(text, mode) {
|
||||||
return this.lines[row] || "";
|
return this.lines[row] || "";
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
|
||||||
* Get a line as it is displayed on screen. Tabs are replaced by spaces.
|
|
||||||
*/
|
|
||||||
this.getDisplayLine = function(row) {
|
|
||||||
var tab = new Array(this.getTabSize()+1).join(" ");
|
|
||||||
return this.lines[row].replace(/\t/g, tab);
|
|
||||||
};
|
|
||||||
|
|
||||||
this.getLines = function(firstRow, lastRow) {
|
this.getLines = function(firstRow, lastRow) {
|
||||||
return this.lines.slice(firstRow, lastRow+1);
|
return this.lines.slice(firstRow, lastRow+1);
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -287,7 +287,7 @@ var Selection = function(doc) {
|
||||||
this.moveCursorLineStart = function() {
|
this.moveCursorLineStart = function() {
|
||||||
var row = this.selectionLead.row;
|
var row = this.selectionLead.row;
|
||||||
var column = this.selectionLead.column;
|
var column = this.selectionLead.column;
|
||||||
var beforeCursor = this.doc.getDisplayLine(row).slice(0, column);
|
var beforeCursor = this.doc.getLine(row).slice(0, column);
|
||||||
var leadingSpace = beforeCursor.match(/^\s+/);
|
var leadingSpace = beforeCursor.match(/^\s+/);
|
||||||
if (!leadingSpace || leadingSpace[0].length >= column)
|
if (!leadingSpace || leadingSpace[0].length >= column)
|
||||||
this.moveCursorTo(this.selectionLead.row, 0);
|
this.moveCursorTo(this.selectionLead.row, 0);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue