Skip to content

Commit

Permalink
[mainloop-] draw new sheets once before execCommand
Browse files Browse the repository at this point in the history
When keys were input extremely quickly, commands were running on
new sheets before they could be drawn and assigned a screen.
  • Loading branch information
midichef committed Apr 9, 2024
1 parent 581cdf1 commit cbb1c49
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 2 additions & 0 deletions visidata/_input.py
Original file line number Diff line number Diff line change
Expand Up @@ -354,6 +354,8 @@ def editText(vd, y, x, w, record=True, display=True, **kwargs):
v = vd.getCommandInput()

if v is None:
if vd.activeSheet._scr is None:
raise Exception('active sheet does not have a screen')

Check failure on line 358 in visidata/_input.py

View workflow job for this annotation

GitHub Actions / run-tests (3.7)

active sheet does not have a screen

Check failure on line 358 in visidata/_input.py

View workflow job for this annotation

GitHub Actions / run-tests (3.8)

active sheet does not have a screen

Check failure on line 358 in visidata/_input.py

View workflow job for this annotation

GitHub Actions / run-tests (3.9)

active sheet does not have a screen
try:
v = vd.editline(vd.activeSheet._scr, y, x, w, display=display, **kwargs)
except AcceptInput as e:
Expand Down
5 changes: 4 additions & 1 deletion visidata/mainloop.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,10 @@ def mainloop(vd, scr):

vd.setWindows(vd.scrFull)

if not vd.drainPendingKeys(scr) or time.time() - vd._lastDrawTime > vd.min_draw_ms/1000: #1459
# a newly created sheet needs to be drawn once to set its _scr
if vd.activeSheet._scr is None or \
not vd.drainPendingKeys(scr) or \
time.time() - vd._lastDrawTime > vd.min_draw_ms/1000: #1459
vd.draw_all()
vd._lastDrawTime = time.time()

Expand Down

0 comments on commit cbb1c49

Please sign in to comment.