X Tutup
Skip to content

Commit dc8f93d

Browse files
committed
add end-of-paste-mode detection for when a string with no linebreaks is pasted
1 parent 5b5730b commit dc8f93d

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

bpython/cli.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -518,6 +518,14 @@ def getargspec(func):
518518

519519
return getargspec(func)
520520

521+
def check(self):
522+
"""Check if paste mode should still be active and, if not, deactivate
523+
it and force syntax highlighting."""
524+
525+
if self.paste_mode and time.time() - self.last_key_press > 0.01:
526+
self.paste_mode = False
527+
self.print_line(self.s)
528+
521529
def complete(self, tab=False):
522530
"""Wrap the _complete method to determine the visibility of list_win
523531
since there can be several reasons why it won't be displayed; this
@@ -1821,6 +1829,7 @@ def idle(caller):
18211829
stdscr.nodelay(False)
18221830
curses.ungetch(key)
18231831
caller.statusbar.check()
1832+
caller.check()
18241833

18251834
if DO_RESIZE:
18261835
do_resize(caller)

0 commit comments

Comments
 (0)
X Tutup