Skip to content

Commit 39fb8f6

Browse files
committed
feat: further optimization of reloads
1 parent 86d3a07 commit 39fb8f6

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

src/widgets/MainPanel.js

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -103,10 +103,10 @@ class MainPanel extends BaseWidget {
103103
}));
104104
}
105105

106-
renderLines() {
106+
renderLines(notify=true) {
107107
this.resetMode();
108108
this.rows = this.lines.slice(this.initialRow, this.initialRow + this.height - 2);
109-
this.update();
109+
this.update(notify);
110110
}
111111

112112
handleKeyPress(ch, key) {
@@ -428,18 +428,20 @@ class MainPanel extends BaseWidget {
428428

429429
moveUp() {
430430
this.row = Math.max(0, this.row - 1);
431-
if (this.row < this.initialRow) {
431+
const outside = this.row < this.initialRow;
432+
if (outside) {
432433
this.initialRow = this.row;
433434
}
434-
this.renderLines();
435+
this.renderLines(outside);
435436
}
436437

437438
moveDown() {
438439
this.row = Math.min(this.lastRow, this.row + 1);
439-
if (this.row > this.lastVisibleLine) {
440+
const outside = this.row > this.lastVisibleLine;
441+
if (outside) {
440442
this.initialRow += 1;
441443
}
442-
this.renderLines();
444+
this.renderLines(outside);
443445
}
444446

445447
firstPage() {
@@ -484,7 +486,7 @@ class MainPanel extends BaseWidget {
484486
return this.initialRow + this.pageHeight;
485487
}
486488

487-
update() {
489+
update(notify=true) {
488490
this.setLabel(`[{bold} ${this.file} {/}] [{bold} ${this.row+1}/${this.lastRow+1} {/}]`);
489491

490492
const columns = [
@@ -507,7 +509,9 @@ class MainPanel extends BaseWidget {
507509
const list = blessed.element({ tags: true, content });
508510
this.append(list);
509511
this.screen.render();
510-
this.setUpdated();
512+
if (notify) {
513+
this.setUpdated();
514+
}
511515
}
512516
}
513517

0 commit comments

Comments
 (0)