MCPcopy
hub / github.com/codeaashu/claude-code / _reflowSmaller

Method _reflowSmaller

src/server/web/public/terminal.js:3958–4010  ·  view source on GitHub ↗
(e3, t3)

Source from the content-addressed store, hash-verified

3956 this.savedY = Math.max(this.savedY - i3, 0);
3957 }
3958 _reflowSmaller(e3, t3) {
3959 const i3 = this.getNullCell(o.DEFAULT_ATTR_DATA), s3 = [];
3960 let r2 = 0;
3961 for (let n2 = this.lines.length - 1; n2 >= 0; n2--) {
3962 let h2 = this.lines.get(n2);
3963 if (!h2 || !h2.isWrapped && h2.getTrimmedLength() <= e3) continue;
3964 const c2 = [h2];
3965 for (; h2.isWrapped && n2 > 0; ) h2 = this.lines.get(--n2), c2.unshift(h2);
3966 const l2 = this.ybase + this.y;
3967 if (l2 >= n2 && l2 < n2 + c2.length) continue;
3968 const d2 = c2[c2.length - 1].getTrimmedLength(), _ = (0, a.reflowSmallerGetNewLineLengths)(c2, this._cols, e3), u = _.length - c2.length;
3969 let f;
3970 f = 0 === this.ybase && this.y !== this.lines.length - 1 ? Math.max(0, this.y - this.lines.maxLength + u) : Math.max(0, this.lines.length - this.lines.maxLength + u);
3971 const v = [];
3972 for (let e4 = 0; e4 < u; e4++) {
3973 const e5 = this.getBlankLine(o.DEFAULT_ATTR_DATA, true);
3974 v.push(e5);
3975 }
3976 v.length > 0 && (s3.push({ start: n2 + c2.length + r2, newLines: v }), r2 += v.length), c2.push(...v);
3977 let p = _.length - 1, g = _[p];
3978 0 === g && (p--, g = _[p]);
3979 let m = c2.length - u - 1, S = d2;
3980 for (; m >= 0; ) {
3981 const e4 = Math.min(S, g);
3982 if (void 0 === c2[p]) break;
3983 if (c2[p].copyCellsFrom(c2[m], S - e4, g - e4, e4, true), g -= e4, 0 === g && (p--, g = _[p]), S -= e4, 0 === S) {
3984 m--;
3985 const e5 = Math.max(m, 0);
3986 S = (0, a.getWrappedLineTrimmedLength)(c2, e5, this._cols);
3987 }
3988 }
3989 for (let t4 = 0; t4 < c2.length; t4++) _[t4] < e3 && c2[t4].setCell(_[t4], i3);
3990 let C = u - f;
3991 for (; C-- > 0; ) 0 === this.ybase ? this.y < t3 - 1 ? (this.y++, this.lines.pop()) : (this.ybase++, this.ydisp++) : this.ybase < Math.min(this.lines.maxLength, this.lines.length + r2) - t3 && (this.ybase === this.ydisp && this.ydisp++, this.ybase++);
3992 this.savedY = Math.min(this.savedY + u, this.ybase + t3 - 1);
3993 }
3994 if (s3.length > 0) {
3995 const e4 = [], t4 = [];
3996 for (let e5 = 0; e5 < this.lines.length; e5++) t4.push(this.lines.get(e5));
3997 const i4 = this.lines.length;
3998 let n2 = i4 - 1, o2 = 0, a2 = s3[o2];
3999 this.lines.length = Math.min(this.lines.maxLength, this.lines.length + r2);
4000 let h2 = 0;
4001 for (let c3 = Math.min(this.lines.maxLength - 1, i4 + r2 - 1); c3 >= 0; c3--) if (a2 && a2.start > n2 + h2) {
4002 for (let e5 = a2.newLines.length - 1; e5 >= 0; e5--) this.lines.set(c3--, a2.newLines[e5]);
4003 c3++, e4.push({ index: n2 + 1, amount: a2.newLines.length }), h2 += a2.newLines.length, a2 = s3[++o2];
4004 } else this.lines.set(c3, t4[n2--]);
4005 let c2 = 0;
4006 for (let t5 = e4.length - 1; t5 >= 0; t5--) e4[t5].index += c2, this.lines.onInsertEmitter.fire(e4[t5]), c2 += e4[t5].amount;
4007 const l2 = Math.max(0, i4 + r2 - this.lines.maxLength);
4008 l2 > 0 && this.lines.onTrimEmitter.fire(l2);
4009 }
4010 }
4011 translateBufferLineToString(e3, t3, i3 = 0, s3) {
4012 const r2 = this.lines.get(e3);
4013 return r2 ? r2.translateToString(t3, i3, s3) : "";

Callers 1

_reflowMethod · 0.80

Calls 11

getNullCellMethod · 0.80
getTrimmedLengthMethod · 0.80
maxMethod · 0.80
getBlankLineMethod · 0.80
copyCellsFromMethod · 0.80
setCellMethod · 0.80
popMethod · 0.80
fireMethod · 0.80
getMethod · 0.65
pushMethod · 0.45
setMethod · 0.45

Tested by

no test coverage detected