Drop one usage of removeLast.
This commit is contained in:
parent
d6b1e36d49
commit
80cd3ca331
@ -238,7 +238,6 @@ export default class Buffer {
|
|||||||
this.removeLast("\n");
|
this.removeLast("\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
this.removeLast(" ");
|
|
||||||
this._removeSpacesAfterLastNewline();
|
this._removeSpacesAfterLastNewline();
|
||||||
for (let j = 0; j < i; j++) {
|
for (let j = 0; j < i; j++) {
|
||||||
this.push("\n");
|
this.push("\n");
|
||||||
@ -250,12 +249,13 @@ export default class Buffer {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
_removeSpacesAfterLastNewline() {
|
_removeSpacesAfterLastNewline() {
|
||||||
let lastNewlineIndex = this.buf.lastIndexOf("\n");
|
const originalBuf = this.buf;
|
||||||
if (lastNewlineIndex >= 0 && this.get().length <= lastNewlineIndex) {
|
this.buf = this.buf.replace(/[ \t]+$/, "");
|
||||||
let toRemove = this.buf.slice(lastNewlineIndex + 1);
|
|
||||||
this.buf = this.buf.substring(0, lastNewlineIndex + 1);
|
if (originalBuf.length !== this.buf.length){
|
||||||
this.last = "\n";
|
const removed = originalBuf.slice(this.buf.length);
|
||||||
this._position.unshift(toRemove);
|
this._position.unshift(removed);
|
||||||
|
this.last = this.buf[this.buf.length - 1];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user