Explorar o código

Fixes a couple of Reflow bugs.

Works a tiny bit better now. Still far from finished
devmil %!s(int64=4) %!d(string=hai) anos
pai
achega
4326fd221f
Modificáronse 2 ficheiros con 5 adicións e 3 borrados
  1. 3 1
      lib/buffer/buffer_line.dart
  2. 2 2
      lib/buffer/buffer_reflow.dart

+ 3 - 1
lib/buffer/buffer_line.dart

@@ -66,8 +66,10 @@ class BufferLine {
     if(_cells.length < requiredCells) {
       _cells.addAll(List<Cell>.generate(requiredCells - _cells.length, (index) => Cell()));
     }
+    //we have to make a copy first as src and dst might be the same line
+    List<Cell> sourceCells = List<Cell>.generate(len, (index) => src._cells[srcCol + index].clone());
     for(var i=0; i<len; i++) {
-      _cells[dstCol + i] = src._cells[srcCol + i].clone();
+      _cells[dstCol + i] = sourceCells[i];
     }
   }
 

+ 2 - 2
lib/buffer/buffer_reflow.dart

@@ -75,7 +75,7 @@ class BufferReflow {
 
       // If these lines contain the cursor don't touch them, the program will handle fixing up
       // wrapped lines with the cursor
-      final absoluteY = _buffer.cursorY - _buffer.scrollOffsetFromBottom;
+      final absoluteY = _buffer.cursorY + _buffer.scrollOffsetFromTop;
 
       if (absoluteY >= y && absoluteY < y + wrappedLines.length) {
         continue;
@@ -376,7 +376,7 @@ class BufferReflow {
         nextLine = _buffer.lines[++i];
       }
 
-      final bufferAbsoluteY = _buffer.cursorY/* - _buffer.scrollOffsetFromBottom*/;
+      final bufferAbsoluteY = _buffer.cursorY + _buffer.scrollOffsetFromTop;
 
       // If these lines contain the cursor don't touch them, the program will handle fixing up wrapped
       // lines with the cursor