Better gathering of lines; don't add extra line terms

This commit is contained in:
Bryan Ashby 2023-08-24 12:12:09 -06:00
parent 0035ef4f39
commit 4d97922933
No known key found for this signature in database
GPG Key ID: C2C1B501E4EFD994
1 changed files with 12 additions and 10 deletions

View File

@ -288,18 +288,20 @@ function MultiLineEditTextView(options) {
this.getOutputText = function (startIndex, endIndex, eolMarker, options) { this.getOutputText = function (startIndex, endIndex, eolMarker, options) {
const lines = self.getTextLines(startIndex, endIndex); const lines = self.getTextLines(startIndex, endIndex);
let text = '';
const re = new RegExp('\\t{1,' + self.tabWidth + '}', 'g'); const re = new RegExp('\\t{1,' + self.tabWidth + '}', 'g');
lines.forEach(line => { return lines
text += line.text.replace(re, '\t'); .map((line, lineIndex) => {
let text = line.text.replace(re, '\t');
if (options.forceLineTerms || (eolMarker && line.eol)) { if (
text += eolMarker; options.forceLineTerms ||
} (eolMarker && line.eol && lineIndex < lines.length - 1)
}); ) {
text += eolMarker;
return text; }
return text;
})
.join();
}; };
this.getContiguousText = function (startIndex, endIndex, includeEol) { this.getContiguousText = function (startIndex, endIndex, includeEol) {