X Tutup
Skip to content

Commit b2a3bf2

Browse files
don't hardcode prompts
1 parent 25a1a60 commit b2a3bf2

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

bpython/curtsiesfrontend/repl.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ def smarter_request_refresh():
233233
self.interact = self.status_bar # overwriting what bpython.Repl put there
234234
# interact is called to interact with the status bar,
235235
# so we're just using the same object
236-
self.current_line = '' # line currently being edited, without '>>> '
236+
self.current_line = '' # line currently being edited, without ps1 (usually ">>> ")
237237
self.current_stdouterr_line = '' # current line of output - stdout and stdin go here
238238
self.display_lines = [] # lines separated whenever logical line
239239
# length goes over what the terminal width
@@ -524,8 +524,10 @@ def send_current_block_to_external_editor(self, filename=None):
524524

525525
def send_session_to_external_editor(self, filename=None):
526526
for_editor = '### current bpython session - file will be reevaluated, ### lines will not be run\n'.encode('utf8')
527-
for_editor += ('\n'.join(line[4:] if line[:4] in ('... ', '>>> ') else '### '+line
528-
for line in self.getstdout().split('\n')).encode('utf8'))
527+
for_editor += ('\n'.join(line[len(self.ps1):] if line.startswith(self.ps1) else
528+
(line[len(self.ps2):] if line.startswith(self.ps2) else
529+
'### '+line)
530+
for line in self.getstdout().split('\n')).encode('utf8'))
529531
text = self.send_to_external_editor(for_editor)
530532
lines = text.split('\n')
531533
self.history = [line for line in lines if line[:4] != '### ']
@@ -549,7 +551,7 @@ def add_normal_character(self, char):
549551
char +
550552
self.current_line[self.cursor_offset:])
551553
self.cursor_offset += 1
552-
if self.config.cli_trim_prompts and self.current_line.startswith(">>> "):
554+
if self.config.cli_trim_prompts and self.current_line.startswith(self.ps1):
553555
self.current_line = self.current_line[4:]
554556
self.cursor_offset = max(0, self.cursor_offset - 4)
555557

0 commit comments

Comments
 (0)
X Tutup