Skip to content

Commit

Permalink
Merge pull request #2378 from midichef/keypresses_screen
Browse files Browse the repository at this point in the history
[mainloop-] prevent input() errors while pasting keys
  • Loading branch information
anjakefala committed May 20, 2024
2 parents 54f8147 + aa9c263 commit 05536fb
Show file tree
Hide file tree
Showing 4 changed files with 8 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')
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
1 change: 1 addition & 0 deletions visidata/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ def curses_setup():
import visidata

curses.curs_set = lambda v: None
curses.doupdate = lambda: None
visidata.options.overwrite = 'always'


Expand Down
1 change: 1 addition & 0 deletions visidata/tests/test_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@ def runOneTest(self, mock_screen, longname):
vd.allSheets = [vs]
vs.mouseX, vs.mouseY = (4, 4)
vs.draw(mock_screen)
vs._scr = mock_screen
if longname in inputLines:
vd.currentReplayRow = vd.cmdlog.newRow(longname=longname, input=inputLines[longname])
else:
Expand Down

0 comments on commit 05536fb

Please sign in to comment.