Clean up a little bit and make current existing unit test run again
This commit is contained in:
parent
1726444b96
commit
12bfd2ee0c
1 changed files with 13 additions and 114 deletions
|
|
@ -1238,64 +1238,8 @@ var EditSession = function(text, mode) {
|
|||
return this.documentToScreenPosition(row, docColumn).column;
|
||||
};
|
||||
|
||||
/**
|
||||
*
|
||||
* @return array[2]
|
||||
* - array[0]: The number of the row on the screen (aka screenRow)
|
||||
* - array[1]: The number of rows from the first docRow on the screen
|
||||
* (aka screenRowOffset);
|
||||
*/
|
||||
this.$documentToScreenRow = function(docRow, docColumn) {
|
||||
if (!this.$useWrapMode) {
|
||||
var row = docRow;
|
||||
row -= this.getFoldedRowLength(0, docRow - 1);
|
||||
|
||||
if (this.isRowFolded(docRow)) {
|
||||
var folds = this.getFoldData(docRow),
|
||||
idx = 0;
|
||||
|
||||
if (folds[0].end.row == docRow) {
|
||||
idx += 1;
|
||||
}
|
||||
|
||||
for (idx; idx < folds.length; idx++) {
|
||||
|
||||
}
|
||||
}
|
||||
return [row, 0];
|
||||
}
|
||||
|
||||
// TODO: WrapMode + Folding
|
||||
|
||||
var wrapData = this.$wrapData;
|
||||
var screenRow = 0;
|
||||
|
||||
// Handle special case where the row is outside of the range of lines.
|
||||
if (docRow > wrapData.length - 1) {
|
||||
return [
|
||||
this.getScreenLength(),
|
||||
wrapData.length == 0 ? 0 : (wrapData[wrapData.length - 1].length - 1)
|
||||
];
|
||||
}
|
||||
|
||||
for (var i = 0; i < docRow; i++) {
|
||||
screenRow += wrapData[i].length + 1;
|
||||
}
|
||||
|
||||
var screenRowOffset = 0;
|
||||
while (docColumn >= wrapData[docRow][screenRowOffset]) {
|
||||
screenRow ++;
|
||||
screenRowOffset++;
|
||||
}
|
||||
|
||||
return [screenRow, screenRowOffset];
|
||||
}
|
||||
|
||||
this.documentToScreenRow = function(docRow, docColumn) {
|
||||
// NEW CODE PATH:
|
||||
var res = this.doc2Screen(docRow, docColumn);
|
||||
return res[0];
|
||||
// return this.$documentToScreenRow(docRow, docColumn)[0];
|
||||
return this.documentToScreenPosition(docRow, docColumn).row;
|
||||
}
|
||||
|
||||
this.$buildWrappedTextLine = function(row, endRow, endColumn) {
|
||||
|
|
@ -1363,10 +1307,9 @@ var EditSession = function(text, mode) {
|
|||
if (!this.isRowVisible(docRow)) {
|
||||
// As the line is not visible, getFoldData will return only a
|
||||
// single fold and also not an array.
|
||||
fold = this.getFoldData(docRow);
|
||||
docRow = fold.start.row;
|
||||
docColumn = fold.start.column;
|
||||
fold = null;
|
||||
var lfold = this.getFoldData(docRow);
|
||||
docRow = lfold.start.row;
|
||||
docColumn = lfold.start.column;
|
||||
}
|
||||
|
||||
for (var row = 0; row < docRow; row++) {
|
||||
|
|
@ -1382,26 +1325,21 @@ var EditSession = function(text, mode) {
|
|||
}
|
||||
}
|
||||
|
||||
// Calculate the text line that is displayed in docRow on the screen.
|
||||
var textLine = "";
|
||||
|
||||
// Check if the final row we want to reach is inside of some folds.
|
||||
// Check if the final row we want to reach is inside of a fold.
|
||||
if (!this.isRowFolded(docRow)) {
|
||||
foldStartRow = null;
|
||||
} else if (!foldStartRow) {
|
||||
foldStartRow = docRow;
|
||||
}
|
||||
|
||||
var wrapDataRow;
|
||||
if (foldStartRow) {
|
||||
textLine = this.$buildWrappedTextLine(
|
||||
foldStartRow, docRow, docColumn);
|
||||
} else {
|
||||
textLine = this.getLine(docRow).substring(0, docColumn);
|
||||
foldStartRow = docRow;
|
||||
} else {
|
||||
textLine = this.$buildWrappedTextLine(
|
||||
(foldStartRow != null ? foldStartRow : docRow), docRow, docColumn);
|
||||
}
|
||||
|
||||
// Clamp textLine if in wrapMode.
|
||||
if (this.$useWrapMode) {
|
||||
var wrapData = this.$wrapData[wrapDataRow];
|
||||
var wrapData = this.$wrapData[foldStartRow];
|
||||
var screenRowOffset = 0;
|
||||
while (docColumn >= wrapData[screenRowOffset]) {
|
||||
screenRow ++;
|
||||
|
|
@ -1410,16 +1348,11 @@ var EditSession = function(text, mode) {
|
|||
textLine = textLine.substring(
|
||||
wrapData[screenRowOffset - 1] || 0, textLine.length);
|
||||
}
|
||||
|
||||
return [screenRow, this.$getStringScreenWidth(textLine), textLine];
|
||||
// return {
|
||||
// row: screenRow,
|
||||
// column: screenColumn
|
||||
// }
|
||||
}
|
||||
|
||||
this.documentToScreenPosition = function(pos, column) {
|
||||
var str;
|
||||
var tabSize = this.getTabSize();
|
||||
|
||||
// Normalize the passed in arguments.
|
||||
var row;
|
||||
if (column != null) {
|
||||
|
|
@ -1435,40 +1368,6 @@ var EditSession = function(text, mode) {
|
|||
row: res[0],
|
||||
column: res[1]
|
||||
};
|
||||
|
||||
if (!this.$useWrapMode) {
|
||||
str = this.getLine(row).substring(0, column);
|
||||
column = this.$getStringScreenWidth(str);
|
||||
return {
|
||||
row: row,
|
||||
column: column
|
||||
};
|
||||
}
|
||||
|
||||
var rowData = this.$documentToScreenRow(row, column);
|
||||
var screenRow = rowData[0];
|
||||
|
||||
if (row >= this.getLength()) {
|
||||
return {
|
||||
row: screenRow,
|
||||
column: 0
|
||||
};
|
||||
}
|
||||
|
||||
var split;
|
||||
var wrapRowData = this.$wrapData[row];
|
||||
var screenColumn;
|
||||
var screenRowOffset = rowData[1];
|
||||
|
||||
// TODO: WrapMode + Code Folding.
|
||||
str = this.getLine(row).substring(
|
||||
wrapRowData[screenRowOffset - 1] || 0, column);
|
||||
screenColumn = this.$getStringScreenWidth(str);
|
||||
|
||||
return {
|
||||
row: screenRow,
|
||||
column: screenColumn
|
||||
};
|
||||
};
|
||||
|
||||
this.getScreenLength = function() {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue