Skip to content

Commit

Permalink
remove_partial_prompt
Browse files Browse the repository at this point in the history
  • Loading branch information
Quentin Peter committed Dec 23, 2020
1 parent cf34d5a commit 3dc4792
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions qtconsole/frontend_widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,19 @@ def copy(self):
elif self._control.hasFocus():
text = self._control.textCursor().selection().toPlainText()
if text:
# Adjust the cursor to not take partial prompts
cursor = self._control.textCursor()
start_pos = cursor.selectionStart()
cursor.setPosition(start_pos)
if (cursor.blockNumber() >=
self._get_prompt_cursor().blockNumber()):
# Only remove partial prompt if in edit area
line_prompt_pos = (
cursor.block().position()
+ len(self._continuation_prompt))
if start_pos < line_prompt_pos:
text = text[(line_prompt_pos - start_pos):]

# Remove prompts.
lines = text.splitlines()
lines = map(self._highlighter.transform_classic_prompt, lines)
Expand Down

0 comments on commit 3dc4792

Please sign in to comment.