Comparing version 3.12.0 to 3.12.1
@@ -181,3 +181,3 @@ "use strict"; | ||
Buffer.prototype._reflowLarger = function (newCols, newRows) { | ||
var toRemove = BufferReflow_1.reflowLargerGetLinesToRemove(this.lines, newCols, this.ybase + this.y); | ||
var toRemove = BufferReflow_1.reflowLargerGetLinesToRemove(this.lines, this._cols, newCols, this.ybase + this.y); | ||
if (toRemove.length > 0) { | ||
@@ -267,3 +267,4 @@ var newLayoutResult = BufferReflow_1.reflowLargerCreateNewLayout(this.lines, toRemove); | ||
srcLineIndex--; | ||
srcCol = wrappedLines[Math.max(srcLineIndex, 0)].getTrimmedLength(); | ||
var wrappedLinesIndex = Math.max(srcLineIndex, 0); | ||
srcCol = BufferReflow_1.getWrappedLineTrimmedLength(wrappedLines, wrappedLinesIndex, this._cols); | ||
} | ||
@@ -270,0 +271,0 @@ } |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var Buffer_1 = require("./Buffer"); | ||
function reflowLargerGetLinesToRemove(lines, newCols, bufferAbsoluteY) { | ||
function reflowLargerGetLinesToRemove(lines, oldCols, newCols, bufferAbsoluteY) { | ||
var toRemove = []; | ||
@@ -22,7 +22,7 @@ for (var y = 0; y < lines.length - 1; y++) { | ||
var destLineIndex = 0; | ||
var destCol = wrappedLines[destLineIndex].getTrimmedLength(); | ||
var destCol = getWrappedLineTrimmedLength(wrappedLines, destLineIndex, oldCols); | ||
var srcLineIndex = 1; | ||
var srcCol = 0; | ||
while (srcLineIndex < wrappedLines.length) { | ||
var srcTrimmedTineLength = wrappedLines[srcLineIndex].getTrimmedLength(); | ||
var srcTrimmedTineLength = getWrappedLineTrimmedLength(wrappedLines, srcLineIndex, oldCols); | ||
var srcRemainingCells = srcTrimmedTineLength - srcCol; | ||
@@ -107,3 +107,3 @@ var destRemainingCells = newCols - destCol; | ||
var newLineLengths = []; | ||
var cellsNeeded = wrappedLines.map(function (l) { return l.getTrimmedLength(); }).reduce(function (p, c) { return p + c; }); | ||
var cellsNeeded = wrappedLines.map(function (l, i) { return getWrappedLineTrimmedLength(wrappedLines, i, oldCols); }).reduce(function (p, c) { return p + c; }); | ||
var srcCol = 0; | ||
@@ -118,3 +118,3 @@ var srcLine = 0; | ||
srcCol += newCols; | ||
var oldTrimmedLength = wrappedLines[srcLine].getTrimmedLength(); | ||
var oldTrimmedLength = getWrappedLineTrimmedLength(wrappedLines, srcLine, oldCols); | ||
if (srcCol > oldTrimmedLength) { | ||
@@ -135,2 +135,15 @@ srcCol -= oldTrimmedLength; | ||
exports.reflowSmallerGetNewLineLengths = reflowSmallerGetNewLineLengths; | ||
function getWrappedLineTrimmedLength(lines, i, cols) { | ||
if (i === lines.length - 1) { | ||
return lines[i].getTrimmedLength(); | ||
} | ||
var cell = lines[i].get(cols - 1); | ||
var endsInNull = cell[Buffer_1.CHAR_DATA_CHAR_INDEX] === '' && cell[Buffer_1.CHAR_DATA_WIDTH_INDEX] === 1; | ||
var followingLineStartsWithWide = lines[i + 1].getWidth(0) === 2; | ||
if (endsInNull && followingLineStartsWithWide) { | ||
return cols - 1; | ||
} | ||
return cols; | ||
} | ||
exports.getWrappedLineTrimmedLength = getWrappedLineTrimmedLength; | ||
//# sourceMappingURL=BufferReflow.js.map |
{ | ||
"name": "xterm", | ||
"description": "Full xterm terminal, in your browser", | ||
"version": "3.12.0", | ||
"version": "3.12.1", | ||
"main": "lib/public/Terminal.js", | ||
@@ -6,0 +6,0 @@ "types": "typings/xterm.d.ts", |
@@ -8,3 +8,3 @@ /** | ||
import { BufferLine } from './BufferLine'; | ||
import { reflowLargerApplyNewLayout, reflowLargerCreateNewLayout, reflowLargerGetLinesToRemove, reflowSmallerGetNewLineLengths } from './BufferReflow'; | ||
import { reflowLargerApplyNewLayout, reflowLargerCreateNewLayout, reflowLargerGetLinesToRemove, reflowSmallerGetNewLineLengths, getWrappedLineTrimmedLength } from './BufferReflow'; | ||
import { CircularList, IDeleteEvent, IInsertEvent } from './common/CircularList'; | ||
@@ -248,3 +248,3 @@ import { EventEmitter } from './common/EventEmitter'; | ||
private _reflowLarger(newCols: number, newRows: number): void { | ||
const toRemove: number[] = reflowLargerGetLinesToRemove(this.lines, newCols, this.ybase + this.y); | ||
const toRemove: number[] = reflowLargerGetLinesToRemove(this.lines, this._cols, newCols, this.ybase + this.y); | ||
if (toRemove.length > 0) { | ||
@@ -353,4 +353,4 @@ const newLayoutResult = reflowLargerCreateNewLayout(this.lines, toRemove); | ||
srcLineIndex--; | ||
// TODO: srcCol shoudl take trimmed length into account | ||
srcCol = wrappedLines[Math.max(srcLineIndex, 0)].getTrimmedLength(); // this._cols; | ||
const wrappedLinesIndex = Math.max(srcLineIndex, 0); | ||
srcCol = getWrappedLineTrimmedLength(wrappedLines, wrappedLinesIndex, this._cols); | ||
} | ||
@@ -357,0 +357,0 @@ } |
@@ -6,3 +6,3 @@ /** | ||
import { FILL_CHAR_DATA } from './Buffer'; | ||
import { FILL_CHAR_DATA, CHAR_DATA_CHAR_INDEX, CHAR_DATA_WIDTH_INDEX } from './Buffer'; | ||
import { BufferLine } from './BufferLine'; | ||
@@ -23,3 +23,3 @@ import { CircularList, IDeleteEvent } from './common/CircularList'; | ||
*/ | ||
export function reflowLargerGetLinesToRemove(lines: CircularList<IBufferLine>, newCols: number, bufferAbsoluteY: number): number[] { | ||
export function reflowLargerGetLinesToRemove(lines: CircularList<IBufferLine>, oldCols: number, newCols: number, bufferAbsoluteY: number): number[] { | ||
// Gather all BufferLines that need to be removed from the Buffer here so that they can be | ||
@@ -53,7 +53,7 @@ // batched up and only committed once | ||
let destLineIndex = 0; | ||
let destCol = wrappedLines[destLineIndex].getTrimmedLength(); | ||
let destCol = getWrappedLineTrimmedLength(wrappedLines, destLineIndex, oldCols); | ||
let srcLineIndex = 1; | ||
let srcCol = 0; | ||
while (srcLineIndex < wrappedLines.length) { | ||
const srcTrimmedTineLength = wrappedLines[srcLineIndex].getTrimmedLength(); | ||
const srcTrimmedTineLength = getWrappedLineTrimmedLength(wrappedLines, srcLineIndex, oldCols); | ||
const srcRemainingCells = srcTrimmedTineLength - srcCol; | ||
@@ -179,3 +179,3 @@ const destRemainingCells = newCols - destCol; | ||
const newLineLengths: number[] = []; | ||
const cellsNeeded = wrappedLines.map(l => l.getTrimmedLength()).reduce((p, c) => p + c); | ||
const cellsNeeded = wrappedLines.map((l, i) => getWrappedLineTrimmedLength(wrappedLines, i, oldCols)).reduce((p, c) => p + c); | ||
@@ -194,3 +194,3 @@ // Use srcCol and srcLine to find the new wrapping point, use that to get the cellsAvailable and | ||
srcCol += newCols; | ||
const oldTrimmedLength = wrappedLines[srcLine].getTrimmedLength(); | ||
const oldTrimmedLength = getWrappedLineTrimmedLength(wrappedLines, srcLine, oldCols); | ||
if (srcCol > oldTrimmedLength) { | ||
@@ -211,1 +211,18 @@ srcCol -= oldTrimmedLength; | ||
} | ||
export function getWrappedLineTrimmedLength(lines: BufferLine[], i: number, cols: number): number { | ||
// If this is the last row in the wrapped line, get the actual trimmed length | ||
if (i === lines.length - 1) { | ||
return lines[i].getTrimmedLength(); | ||
} | ||
// Detect whether the following line starts with a wide character and the end of the current line | ||
// is null, if so then we can be pretty sure the null character should be excluded from the line | ||
// length] | ||
const cell = lines[i].get(cols - 1); | ||
const endsInNull = cell[CHAR_DATA_CHAR_INDEX] === '' && cell[CHAR_DATA_WIDTH_INDEX] === 1; | ||
const followingLineStartsWithWide = lines[i + 1].getWidth(0) === 2; | ||
if (endsInNull && followingLineStartsWithWide) { | ||
return cols - 1; | ||
} | ||
return cols; | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
4
1414580
268
26208