Просмотр исходного кода

Respect double width cells during reflow wider

and not copy it when the line length would be too much
devmil 4 лет назад
Родитель
Сommit
90c154ce36
1 измененных файлов с 7 добавлено и 5 удалено
  1. 7 5
      lib/buffer/reflow_strategy_wider.dart

+ 7 - 5
lib/buffer/reflow_strategy_wider.dart

@@ -11,6 +11,7 @@ class ReflowStrategyWider extends ReflowStrategy {
   void reflow(int newCols, int newRows, int oldCols, int oldRows) {
     for (var i = 0; i < buffer.lines.length; i++) {
       final line = buffer.lines[i];
+      line.ensure(newCols);
       for (var offset = 1; i + offset < buffer.lines.length; offset++) {
         final nextLine = buffer.lines[i + offset];
         if (!nextLine.isWrapped) {
@@ -38,11 +39,12 @@ class ReflowStrategyWider extends ReflowStrategy {
         }
 
         // when we are about to copy a double width character
-        // to the end of the line then we can include the 0 width placeholder
-        // after it
-        if (nextLine.cellGetWidth(moveCount - 1) == 2 &&
-            nextLine.cellGetContent(moveCount) == 0) {
-          moveCount += 1;
+        // to the end of the line then we just ignore it as the target width
+        // would be too much
+        if (moveCount >= 2 &&
+            nextLine.cellGetWidth(moveCount - 1) == 2 &&
+            nextLine.cellGetContent(moveCount - 2) == 0) {
+          moveCount -= 1;
         }
         line.copyCellsFrom(nextLine, 0, copyDestIndex, moveCount);
         if (moveCount >= nextLineLength) {