moz-import: don't add an extra newline before the last line
This commit is contained in:
parent
3287b79f5e
commit
c815263671
14
edit.js
14
edit.js
|
@ -1364,7 +1364,7 @@ function fromMozillaFormat() {
|
||||||
section.code = gapComment[1] + "\n";
|
section.code = gapComment[1] + "\n";
|
||||||
outerText = trimNewLines(outerText.substring(0, gapComment.index));
|
outerText = trimNewLines(outerText.substring(0, gapComment.index));
|
||||||
}
|
}
|
||||||
if (outerText) {
|
if (outerText.trim()) {
|
||||||
sectionStack.last.code = outerText;
|
sectionStack.last.code = outerText;
|
||||||
doAddSection(sectionStack.last);
|
doAddSection(sectionStack.last);
|
||||||
sectionStack.last.code = "";
|
sectionStack.last.code = "";
|
||||||
|
@ -1412,12 +1412,14 @@ function fromMozillaFormat() {
|
||||||
parser.parse(mozStyle);
|
parser.parse(mozStyle);
|
||||||
|
|
||||||
function getRange( start, end) {
|
function getRange( start, end) {
|
||||||
if (start.line == end.line) {
|
const L1 = start.line - 1, C1 = start.col - 1;
|
||||||
return lines[start.line - 1].substr(start.col - 1, end.col - start.col + 1).trim();
|
const L2 = end.line - 1, C2 = end.col - 1;
|
||||||
|
if (L1 == L2) {
|
||||||
|
return lines[L1].substr(C1, C2 - C1 + 1);
|
||||||
} else {
|
} else {
|
||||||
return trimNewLines(lines[start.line - 1].substr(start.col - 1) + "\n" +
|
const middle = lines.slice(L1 + 1, L2).join('\n');
|
||||||
lines.slice(start.line, end.line - 1).join("\n") +
|
return lines[L1].substr(C1) + '\n' + middle +
|
||||||
"\n" + lines[end.line - 1].substring(0, end.col - 1));
|
(L2 >= lines.length ? '' : ((middle ? '\n' : '') + lines[L2].substring(0, C2)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
function doAddSection(section) {
|
function doAddSection(section) {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user