Skip to content

bpo-39852: IDLE 'Go to line' deletes selection, updates status #18801

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

Merged
merged 6 commits into from
Mar 8, 2020

Conversation

terryjreedy
Copy link
Member

@terryjreedy terryjreedy commented Mar 6, 2020

Clearing any selection prevents accidental deletion.
The update is for Ln and Col on the status bar.

https://bugs.python.org/issue39852

Clearing any selection prevents accidental deletion.
The update is for Ln and Col on the status bar.
@terryjreedy
Copy link
Member Author

terryjreedy commented Mar 6, 2020

@taleinat @csabella It would be nice to have this tested on Mac and Linux (Ubuntu). A minimal test: in shell, enter something after the prompt and select some of it. Open goto box, enter 2, close by clicking OK Selected text should remain but selection highlight should be gone. Status bar should be updated. Previously, at least on windows, selection highlight remained and status Ln, Col were not updated. For more: Repeat but close with Enter key, and without selection. Everything should work in editor too.

Edit: I previously forgot to include the '@'s to get this emailed to you. I plan to merge tomorrow to work on at least one of two other issues touching the function, but testing after merge, or after another patch or two, before the next releases, would still be good. The simulated click is needed, at least on Windows, where selection_clear does not completely clear physical click selections. The more direct code I would have preferred would have been 3 lines instead of 5.

@terryjreedy
Copy link
Member Author

The patch to idlelib/help.html included changes to idle.rst in #18771 that were not propagated.

@@ -678,8 +678,13 @@ def goto_line_event(self, event):
if lineno <= 0:
text.bell()
return "break"
text.mark_set("insert", "%d.0" % lineno)
newindex = f'{lineno}.0'
text.mark_set("insert", newindex )
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rogue extra space after newindex.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In response to next comment, I reverted mark_set change.

@csabella
Copy link
Contributor

csabella commented Mar 8, 2020

There's a remove_selection method in editor.py. I looked at what you had written, but it seems that using remove_selection (with or without selection_clear()) fixes the issue. Since you didn't mention calling remove_selection, I was wondering if you tried it?

@terryjreedy
Copy link
Member Author

terryjreedy commented Mar 8, 2020

I was not currently aware of it. Since I want .see after .mark_set, I pulled in .tag_remove, which for some reason I did not think was working. But it does here. Thank you.

Copy link
Contributor

@csabella csabella left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. This works on Ubuntu.

@terryjreedy terryjreedy merged commit 2522db1 into python:master Mar 8, 2020
@miss-islington
Copy link
Contributor

Thanks @terryjreedy for the PR 🌮🎉.. I'm working now to backport this PR to: 3.7, 3.8.
🐍🍒⛏🤖

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Mar 8, 2020
…nGH-18801)

It appears standard that moving the text insert cursor away from a selection clears the
selection.  Clearing prevents accidental deletion of a possibly off-screen bit of text.
The update is for Ln and Col on the status bar.
(cherry picked from commit 2522db1)

Co-authored-by: Terry Jan Reedy <[email protected]>
@bedevere-bot
Copy link

GH-18857 is a backport of this pull request to the 3.8 branch.

@terryjreedy terryjreedy deleted the goto-text branch March 8, 2020 18:32
@bedevere-bot
Copy link

GH-18858 is a backport of this pull request to the 3.7 branch.

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Mar 8, 2020
…nGH-18801)

It appears standard that moving the text insert cursor away from a selection clears the
selection.  Clearing prevents accidental deletion of a possibly off-screen bit of text.
The update is for Ln and Col on the status bar.
(cherry picked from commit 2522db1)

Co-authored-by: Terry Jan Reedy <[email protected]>
miss-islington added a commit that referenced this pull request Mar 8, 2020
)

It appears standard that moving the text insert cursor away from a selection clears the
selection.  Clearing prevents accidental deletion of a possibly off-screen bit of text.
The update is for Ln and Col on the status bar.
(cherry picked from commit 2522db1)

Co-authored-by: Terry Jan Reedy <[email protected]>
miss-islington added a commit that referenced this pull request Mar 8, 2020
)

It appears standard that moving the text insert cursor away from a selection clears the
selection.  Clearing prevents accidental deletion of a possibly off-screen bit of text.
The update is for Ln and Col on the status bar.
(cherry picked from commit 2522db1)

Co-authored-by: Terry Jan Reedy <[email protected]>
@terryjreedy
Copy link
Member Author

I should remember to use Module Browser to scan the 100+ EditorWindow methods.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants