Skip to content

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

Merged
terryjreedy merged 6 commits into
python:masterfrom
terryjreedy:goto-text
Mar 8, 2020
Merged

bpo-39852: IDLE 'Go to line' deletes selection, updates status#18801
terryjreedy merged 6 commits into
python:masterfrom
terryjreedy:goto-text

Conversation

@terryjreedy

@terryjreedy terryjreedy commented Mar 6, 2020

Copy link
Copy Markdown
Member

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

terryjreedy commented Mar 6, 2020

Copy link
Copy Markdown
Member Author

@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
Copy Markdown
Member Author

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

Comment thread Lib/idlelib/editor.py Outdated
return "break"
text.mark_set("insert", "%d.0" % lineno)
newindex = f'{lineno}.0'
text.mark_set("insert", newindex )

Copy link
Copy Markdown
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
Copy Markdown
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

csabella commented Mar 8, 2020

Copy link
Copy Markdown
Contributor

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

terryjreedy commented Mar 8, 2020

Copy link
Copy Markdown
Member Author

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.

@csabella csabella left a comment

Copy link
Copy Markdown
Contributor

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
Copy Markdown
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 <tjreedy@udel.edu>
@bedevere-bot

Copy link
Copy Markdown

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
Copy Markdown

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 <tjreedy@udel.edu>
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 <tjreedy@udel.edu>
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 <tjreedy@udel.edu>
@terryjreedy

Copy link
Copy Markdown
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