rename to copyFrom; use _push for JSArray based bufferline

This commit is contained in:
Jörg Breitbart
2018-09-08 17:51:22 +02:00
parent bc943b7b57
commit d4f7c6bcf5
3 changed files with 8 additions and 8 deletions
+3 -3
View File
@@ -108,7 +108,7 @@ describe('BufferLine', function(): void {
chai.expect(line2.length).equals(line.length);
chai.expect(line2.isWrapped).equals(line.isWrapped);
});
it('makeCopyOf', function(): void {
it('copyFrom', function(): void {
const line = new TestBufferLine(5);
line.set(0, [1, 'a', 0, 'a'.charCodeAt(0)]);
line.set(1, [2, 'b', 0, 'b'.charCodeAt(0)]);
@@ -116,7 +116,7 @@ describe('BufferLine', function(): void {
line.set(3, [4, 'd', 0, 'd'.charCodeAt(0)]);
line.set(4, [5, 'e', 0, 'e'.charCodeAt(0)]);
const line2 = new TestBufferLine(5, [1, 'a', 0, 'a'.charCodeAt(0)], true);
line2.makeCopyOf(line);
line2.copyFrom(line);
chai.expect(line2.toArray()).eql(line.toArray());
chai.expect(line2.length).equals(line.length);
chai.expect(line2.isWrapped).equals(line.isWrapped);
@@ -128,7 +128,7 @@ describe('BufferLine', function(): void {
const line = new TestBufferLine(2, [1, 'e\u0301', 0, '\u0301'.charCodeAt(0)]);
chai.expect(line.toArray()).eql([[1, 'e\u0301', 0, '\u0301'.charCodeAt(0)], [1, 'e\u0301', 0, '\u0301'.charCodeAt(0)]]);
const line2 = new TestBufferLine(5, [1, 'a', 0, '\u0301'.charCodeAt(0)], true);
line2.makeCopyOf(line);
line2.copyFrom(line);
chai.expect(line2.toArray()).eql(line.toArray());
const line3 = line.clone();
chai.expect(TestBufferLine.prototype.toArray.apply(line3)).eql(line.toArray());
+4 -4
View File
@@ -94,10 +94,10 @@ export class BufferLine implements IBufferLine {
}
}
public makeCopyOf(line: IBufferLine): void {
public copyFrom(line: IBufferLine): void {
this._data = [];
for (let i = 0; i < line.length; ++i) {
this.set(i, line.get(i));
this._push(line.get(i));
}
this.length = line.length;
this.isWrapped = line.isWrapped;
@@ -105,7 +105,7 @@ export class BufferLine implements IBufferLine {
public clone(): IBufferLine {
const newLine = new BufferLine(0);
newLine.makeCopyOf(this);
newLine.copyFrom(this);
return newLine;
}
}
@@ -242,7 +242,7 @@ export class BufferLineTypedArray implements IBufferLine {
}
/** alter to a full copy of line */
public makeCopyOf(line: BufferLineTypedArray): void {
public copyFrom(line: BufferLineTypedArray): void {
if (this.length !== line.length) {
this._data = new Uint32Array(line._data);
} else {
+1 -1
View File
@@ -508,7 +508,7 @@ export interface IBufferLine {
replaceCells(start: number, end: number, fill: CharData): void;
resize(cols: number, fill: CharData, shrink?: boolean): void;
fill(fillCharData: CharData): void;
makeCopyOf(line: IBufferLine): void;
copyFrom(line: IBufferLine): void;
clone(): IBufferLine;
}