mirror of
https://github.com/python/cpython.git
synced 2025-08-04 08:59:19 +00:00
gh-95511: IDLE - fix Shell context menu copy-with-prompts bug (#95512)
If one selects whole lines, as the sidebar makes easy, do not add an extra line. Only move the end of a selection to the beginning of the next line when not already at the beginning of a line. (Also improve the surrounding code.)
This commit is contained in:
parent
d29e279de3
commit
fc31a13dc1
4 changed files with 18 additions and 14 deletions
|
@ -996,19 +996,17 @@ class PyShell(OutputWindow):
|
|||
and/or last lines is selected.
|
||||
"""
|
||||
text = self.text
|
||||
selfirst = text.index('sel.first linestart')
|
||||
if selfirst is None: # Should not be possible.
|
||||
return # No selection, do nothing.
|
||||
sellast = text.index('sel.last')
|
||||
if sellast[-1] != '0':
|
||||
sellast = text.index("sel.last+1line linestart")
|
||||
|
||||
selection_indexes = (
|
||||
self.text.index("sel.first linestart"),
|
||||
self.text.index("sel.last +1line linestart"),
|
||||
)
|
||||
if selection_indexes[0] is None:
|
||||
# There is no selection, so do nothing.
|
||||
return
|
||||
|
||||
selected_text = self.text.get(*selection_indexes)
|
||||
selected_text = self.text.get(selfirst, sellast)
|
||||
selection_lineno_range = range(
|
||||
int(float(selection_indexes[0])),
|
||||
int(float(selection_indexes[1]))
|
||||
int(float(selfirst)),
|
||||
int(float(sellast))
|
||||
)
|
||||
prompts = [
|
||||
self.shell_sidebar.line_prompts.get(lineno)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue