Don't leave extra whitespace around slots

This commit is contained in:
Patrick Steele-Idem 2016-02-04 17:08:13 -07:00
parent e27e680367
commit 7f65aade1d

View File

@ -82,7 +82,19 @@ class Slot {
let beforeCode = oldCode.substring(0, this._start);
let afterCode = oldCode.substring(this._end);
codegen._code = beforeCode + (slotCode || '') + afterCode;
if (slotCode) {
codegen._code = beforeCode + slotCode + afterCode;
} else {
let beforeWhitespaceMatches = beforeCode.match(/[\n]\s*$/);
if (beforeWhitespaceMatches != null) {
let beforeWhitespace = beforeWhitespaceMatches[0];
if (afterCode.startsWith(beforeWhitespace)) {
afterCode = afterCode.substring(beforeWhitespace.length);
}
}
codegen._code = beforeCode + afterCode;
}
}
}