Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[mainloop-] prevent input() errors while pasting keys #2378

Merged
merged 1 commit into from
May 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -178,6 +178,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
Loading