Get reflow smaller working for wide chars

This commit is contained in:
Daniel Imms
2019-01-23 22:40:40 -08:00
parent ce69dceee7
commit df7cd9c319
4 changed files with 32 additions and 11 deletions
+9 -8
View File
@@ -80,21 +80,22 @@ export function reflowSmallerGetNewLineLengths(wrappedLines: BufferLine[], oldCo
// Use srcCol and srcLine to find the new wrapping point, use that to get the cellsAvailable and
// linesNeeded
let srcCol = -1;
let srcCol = 0;
let srcLine = 0;
let cellsAvailable = 0;
while (cellsAvailable < cellsNeeded) {
srcCol += newCols;
if (srcCol >= oldCols) {
srcCol -= oldCols;
srcLine++;
}
if (srcLine >= wrappedLines.length) {
if (cellsNeeded - cellsAvailable < newCols) {
// Add the final line and exit the loop
newLineLengths.push(cellsNeeded - cellsAvailable);
break;
}
const endsWithWide = wrappedLines[srcLine].getWidth(srcCol) === 2;
srcCol += newCols;
const oldTrimmedLength = wrappedLines[srcLine].getTrimmedLength();
if (srcCol > oldTrimmedLength) {
srcCol -= oldTrimmedLength;
srcLine++;
}
const endsWithWide = wrappedLines[srcLine].getWidth(srcCol - 1) === 2;
if (endsWithWide) {
srcCol--;
}