Parcourir la source

Merge adaptions

devmil il y a 4 ans
Parent
commit
92ef846089

+ 1 - 3
lib/buffer/buffer.dart

@@ -485,9 +485,7 @@ class Buffer {
 
   void resize(int oldWidth, int oldHeight, int newWidth, int newHeight) {
     if (newWidth > oldWidth) {
-      lines.forEach((item, index) {
-        item?.ensure(newWidth);
-      });
+      lines.forEach((item) => item.ensure(newWidth));
     }
 
     if (newHeight > oldHeight) {

+ 3 - 27
lib/buffer/reflow_strategy_narrower.dart

@@ -18,7 +18,7 @@ class ReflowStrategyNarrower extends ReflowStrategy {
     // Go backwards as many lines may be trimmed and this will avoid considering them
     for (int y = buffer.lines.length - 1; y >= 0; y--) {
       // Check whether this line is a problem or not, if not skip it
-      BufferLine nextLine = buffer.lines[y]!;
+      BufferLine nextLine = buffer.lines[y];
       int lineLength = nextLine.getTrimmedLength(oldCols);
       if (!nextLine.isWrapped && lineLength <= newCols) {
         continue;
@@ -28,7 +28,7 @@ class ReflowStrategyNarrower extends ReflowStrategy {
       final wrappedLines = List<BufferLine>.empty(growable: true);
       wrappedLines.add(nextLine);
       while (nextLine.isWrapped && y > 0) {
-        nextLine = buffer.lines[--y]!;
+        nextLine = buffer.lines[--y];
         wrappedLines.insert(0, nextLine);
       }
 
@@ -110,15 +110,11 @@ class ReflowStrategyNarrower extends ReflowStrategy {
     // than earlier so that it's a single O(n) pass through the buffer, instead of O(n^2) from many
     // costly calls to CircularList.splice.
     if (toInsert.length > 0) {
-      // Record buffer insert events and then play them back backwards so that the indexes are
-      // correct
-      List<int> insertEvents = List<int>.empty(growable: true);
-
       // Record original lines so they don't get overridden when we rearrange the list
       CircularList<BufferLine> originalLines =
           new CircularList<BufferLine>(buffer.lines.maxLength);
       for (int i = 0; i < buffer.lines.length; i++) {
-        originalLines.push(buffer.lines[i]!);
+        originalLines.push(buffer.lines[i]);
       }
 
       int originalLinesLength = buffer.lines.length;
@@ -151,12 +147,6 @@ class ReflowStrategyNarrower extends ReflowStrategy {
 
           i++;
 
-          // Create insert events for later
-          //insertEvents.Add ({
-          //	index: originalLineIndex + 1,
-          //	amount: nextToInsert.newLines.length
-          //});
-
           countInsertedSoFar += nextToInsert.lines!.length;
           if (nextToInsertIndex < toInsert.length - 1) {
             nextToInsert = toInsert[++nextToInsertIndex];
@@ -167,20 +157,6 @@ class ReflowStrategyNarrower extends ReflowStrategy {
           buffer.lines[i] = originalLines[originalLineIndex--];
         }
       }
-
-      /*
-				// Update markers
-				let insertCountEmitted = 0;
-				for (let i = insertEvents.length - 1; i >= 0; i--) {
-					insertEvents [i].index += insertCountEmitted;
-					this.lines.onInsertEmitter.fire (insertEvents [i]);
-					insertCountEmitted += insertEvents [i].amount;
-				}
-				const amountToTrim = Math.max (0, originalLinesLength + countToInsert - this.lines.maxLength);
-				if (amountToTrim > 0) {
-					this.lines.onTrimEmitter.fire (amountToTrim);
-				}
-				*/
     }
   }
 

+ 4 - 4
lib/buffer/reflow_strategy_wider.dart

@@ -36,17 +36,17 @@ class ReflowStrategyWider extends ReflowStrategy {
     for (int y = 0; y < lines.length - 1; y++) {
       // Check if this row is wrapped
       int i = y;
-      BufferLine nextLine = lines[++i]!;
+      BufferLine nextLine = lines[++i];
       if (!nextLine.isWrapped) {
         continue;
       }
 
       // Check how many lines it's wrapped for
       final wrappedLines = List<BufferLine>.empty(growable: true);
-      wrappedLines.add(lines[y]!);
+      wrappedLines.add(lines[y]);
       while (i < lines.length && nextLine.isWrapped) {
         wrappedLines.add(nextLine);
-        nextLine = lines[++i]!;
+        nextLine = lines[++i];
       }
 
       final bufferAbsoluteY = buffer.cursorY + buffer.scrollOffsetFromTop;
@@ -163,7 +163,7 @@ class ReflowStrategyWider extends ReflowStrategy {
     var newLayoutLines = new CircularList<BufferLine>(lines.length);
 
     for (int i = 0; i < newLayout.length; i++) {
-      newLayoutLines.push(lines[newLayout[i]!]!);
+      newLayoutLines.push(lines[newLayout[i]]);
     }
 
     // Rearrange the list