Simplify Document.computeWrapSplits
This commit is contained in:
parent
e01c59a8db
commit
700a647148
1 changed files with 2 additions and 23 deletions
|
|
@ -862,10 +862,12 @@ var Document = function(text, mode) {
|
|||
};
|
||||
|
||||
this.$computeWrapSplits = function(textLine, wrapLimit, tabSize) {
|
||||
textLine = textLine.trimRight();
|
||||
if (textLine.length == 0) {
|
||||
return [];
|
||||
}
|
||||
|
||||
var reSpaces = /^\s*$/;
|
||||
var tabLine = textLine.split("\t");
|
||||
var wrapSplits = [];
|
||||
|
||||
|
|
@ -873,29 +875,6 @@ var Document = function(text, mode) {
|
|||
var documentColumn = 0;
|
||||
var lastSplitColumn = 0;
|
||||
|
||||
var reSpaces = /^\s*$/;
|
||||
|
||||
// Remove all tablines from the end of the tabLine array that are empty
|
||||
// or contain only space. This is necessary to prevent splits at the
|
||||
// line end if only tabs/spaces are following.
|
||||
// E.g: "foo bar\t " -> "foo bar".
|
||||
var toRemove = tabLine.length - 1;
|
||||
while (toRemove != -1 && reSpaces.test(tabLine[toRemove])) {
|
||||
toRemove --;
|
||||
}
|
||||
tabLine.splice(toRemove + 1);
|
||||
|
||||
// Shortcut: If there are no more tabLines, then there is nothing to
|
||||
// split up.
|
||||
if (tabLine.length == 0) {
|
||||
return [];
|
||||
}
|
||||
|
||||
// Remove spaces from the last tabLine to prevent splits only for
|
||||
// whitespaces as well.
|
||||
// E.g: "foo \tbar " -> "foo \tbar"
|
||||
tabLine[tabLine.length - 1] = tabLine[tabLine.length - 1].trimRight();
|
||||
|
||||
var value;
|
||||
var addedNewSplit;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue