Skip to content

Commit

Permalink
Remove out param from reflow large method
Browse files Browse the repository at this point in the history
  • Loading branch information
Tyriar committed Jan 24, 2019
1 parent d4bd8ae commit 99ac780
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
7 changes: 3 additions & 4 deletions src/Buffer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -242,10 +242,9 @@ export class Buffer implements IBuffer {
private _reflowLarger(newCols: number): void {
const toRemove: number[] = reflowLargerGetLinesToRemove(this.lines, newCols);
if (toRemove.length > 0) {
const newLayout: number[] = [];
const countRemoved = reflowLargerCreateNewLayout(this.lines, toRemove, newLayout);
reflowLargerApplyNewLayout(this.lines, newLayout);
this._reflowLargerAdjustViewport(newCols, countRemoved);
const newLayoutResult = reflowLargerCreateNewLayout(this.lines, toRemove);
reflowLargerApplyNewLayout(this.lines, newLayoutResult.layout);
this._reflowLargerAdjustViewport(newCols, newLayoutResult.countRemoved);
}
}

Expand Down
15 changes: 12 additions & 3 deletions src/BufferReflow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@ import { CircularList, IDeleteEvent } from './common/CircularList';
import { IBufferLine } from './Types';
import { FILL_CHAR_DATA } from './Buffer';

export interface INewLayoutResult {
layout: number[];
countRemoved: number;
}

export function reflowLargerGetLinesToRemove(lines: CircularList<IBufferLine>, newCols: number): number[] {
// Gather all BufferLines that need to be removed from the Buffer here so that they can be
// batched up and only committed once
Expand Down Expand Up @@ -85,7 +90,8 @@ export function reflowLargerGetLinesToRemove(lines: CircularList<IBufferLine>, n
return toRemove;
}

export function reflowLargerCreateNewLayout(lines: CircularList<IBufferLine>, toRemove: number[], newLayout: number[]): number {
export function reflowLargerCreateNewLayout(lines: CircularList<IBufferLine>, toRemove: number[]): INewLayoutResult {
const layout: number[] = [];
// First iterate through the list and get the actual indexes to use for rows
let nextToRemoveIndex = 0;
let nextToRemoveStart = toRemove[nextToRemoveIndex];
Expand All @@ -104,10 +110,13 @@ export function reflowLargerCreateNewLayout(lines: CircularList<IBufferLine>, to
countRemovedSoFar += countToRemove;
nextToRemoveStart = toRemove[++nextToRemoveIndex];
} else {
newLayout.push(i);
layout.push(i);
}
}
return countRemovedSoFar;
return {
layout,
countRemoved: countRemovedSoFar
};
}

export function reflowLargerApplyNewLayout(lines: CircularList<IBufferLine>, newLayout: number[]): void {
Expand Down

0 comments on commit 99ac780

Please sign in to comment.