Implement Document.getScreenRowLength and fix bug if full line seleciton is turned off
This commit is contained in:
parent
0a0db83072
commit
40472b71fc
2 changed files with 34 additions and 14 deletions
|
|
@ -1008,6 +1008,23 @@ var Document = function(text, mode) {
|
|||
return rows * config.lineHeight;
|
||||
};
|
||||
|
||||
this.getScreenRowLength = function(screenRow) {
|
||||
if (!this.$useWrapMode) {
|
||||
return this.getLine(screenRow).length;
|
||||
}
|
||||
|
||||
var rowData = this.$screenToDocumentRow(screenRow);
|
||||
var docRow = rowData[0],
|
||||
row = rowData[1];
|
||||
|
||||
if (this.$wrapData[docRow][row]) {
|
||||
return this.$wrapData[docRow][row] - (this.$wrapData[docRow][row - 1] || 0);
|
||||
} else {
|
||||
return this.lines[docRow].length -
|
||||
(this.$wrapData[docRow][row - 1] || 0) ;
|
||||
}
|
||||
};
|
||||
|
||||
this.getRowSplitData = function(row) {
|
||||
if (!this.$useWrapMode) {
|
||||
return undefined;
|
||||
|
|
@ -1016,13 +1033,9 @@ var Document = function(text, mode) {
|
|||
}
|
||||
};
|
||||
|
||||
this.screenToDocumentColumn = function(row, screenColumn) {
|
||||
return this.screenToDocumentPosition(row, screenColumn).column;
|
||||
};
|
||||
|
||||
this.screenToDocumentRow = function(row) {
|
||||
this.$screenToDocumentRow = function(row) {
|
||||
if (!this.$useWrapMode) {
|
||||
return row;
|
||||
return [row, 0];
|
||||
}
|
||||
|
||||
var wrapData = this.$wrapData, linesCount = this.lines.length;
|
||||
|
|
@ -1032,7 +1045,15 @@ var Document = function(text, mode) {
|
|||
docRow ++;
|
||||
}
|
||||
|
||||
return docRow;
|
||||
return [docRow, row];
|
||||
};
|
||||
|
||||
this.screenToDocumentRow = function(screenRow) {
|
||||
return this.$screenToDocumentRow(screenRow)[0];
|
||||
};
|
||||
|
||||
this.screenToDocumentColumn = function(screenRow, screenColumn) {
|
||||
return this.screenToDocumentPosition(screenRow, screenColumn).column;
|
||||
};
|
||||
|
||||
this.screenToDocumentPosition = function(row, column) {
|
||||
|
|
@ -1047,11 +1068,9 @@ var Document = function(text, mode) {
|
|||
} else {
|
||||
var wrapData = this.$wrapData, linesCount = this.lines.length;
|
||||
|
||||
docRow = 0;
|
||||
while (docRow < linesCount && row >= wrapData[docRow].length + 1) {
|
||||
row -= wrapData[docRow].length + 1;
|
||||
docRow ++;
|
||||
}
|
||||
var rowData = this.$screenToDocumentRow(row);
|
||||
var row = rowData[1];
|
||||
docRow = rowData[0];
|
||||
|
||||
if (docRow >= this.lines.length) {
|
||||
return {
|
||||
|
|
|
|||
|
|
@ -110,7 +110,8 @@ var Marker = function(parentEl) {
|
|||
this.drawTextMarker = function(stringBuilder, range, clazz, layerConfig) {
|
||||
// selection start
|
||||
var row = range.start.row;
|
||||
var lineRange = new Range(row, range.start.column, row, this.doc.getLine(row).length);
|
||||
var lineRange = new Range(row, range.start.column,
|
||||
row, this.doc.getScreenRowLength(row));
|
||||
this.drawSingleLineMarker(stringBuilder, lineRange, clazz, layerConfig);
|
||||
|
||||
// selection end
|
||||
|
|
@ -121,7 +122,7 @@ var Marker = function(parentEl) {
|
|||
for (var row = range.start.row + 1; row < range.end.row; row++) {
|
||||
lineRange.start.row = row;
|
||||
lineRange.end.row = row;
|
||||
lineRange.end.column = this.doc.getLine(row).length;
|
||||
lineRange.end.column = this.doc.getScreenRowLength(row);
|
||||
this.drawSingleLineMarker(stringBuilder, lineRange, clazz, layerConfig);
|
||||
}
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue