This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: IDLE: Goto should remove selection and update the status bar
Type: behavior Stage: resolved
Components: IDLE Versions: Python 3.9, Python 3.8, Python 3.7
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: terry.reedy Nosy List: Dave Liptack, gvanrossum, miss-islington, terry.reedy
Priority: normal Keywords: patch

Created on 2020-03-04 18:12 by Dave Liptack, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
selection_clear.py terry.reedy, 2020-03-06 06:36
Pull Requests
URL Status Linked Edit
PR 18801 merged terry.reedy, 2020-03-06 06:59
PR 18857 merged miss-islington, 2020-03-08 18:32
PR 18858 merged miss-islington, 2020-03-08 18:33
Messages (15)
msg363370 - (view) Author: Dave Liptack (Dave Liptack) Date: 2020-03-04 18:12
Python 3.8.1
IDLE 3.8.1

When COPYing text in IDLE, right-click and PASTE behaves like CUT/PASTE

This also occurs with COPY -> Go to Line -> PASTE

This does not occur with COPY -> left-click -> PASTE
msg363392 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2020-03-04 21:39
The standard and expected behavior is that pasting *without* a selection inserts, pasting *with* a selection replaces.  Pasting with key, Edit menu, or context menu should be the same.  This is what I see and what I *think* you are describing.  If so, please close.  If not, please specify OS and version, how you installed Python, and more concretely what you did and whether line numbers or code context were present.
msg363439 - (view) Author: Dave Liptack (Dave Liptack) Date: 2020-03-05 16:05
OS: Windows 10 Pro
Version: 1909
OS Build: 18363.657

Python 2.7.17 and 3.8.1 were installed from https://www.python.org/downloads/ using the Windows x86-64 executable installer (3.8.1) and Windows x86-64 MSI installer (2.7.17)

Both line numbers and code context are not present

To reproduce:
1) Position cursor at the start of a line of text
2) Type Shift+down arrow (to select line of text)
3) Type Ctrl+c
4) Type Alt+g (IDLE) or Ctrl+g (Notepad, Notepad++)
5) Enter line number (for example below line number = 2)
6) Type Enter
7) Type Ctrl+v


Example initial text:
# This is line 1

# additional line
# This is a line I wish to duplicate
# another additional line


Resulting text in IDLE:
# This is line 1
# This is a line I wish to duplicate

# additional line
# another additional line


Resulting text in Notepad and Notepad++:
# This is line 1
# This is a line I wish to duplicate

# additional line
# This is a line I wish to duplicate
# another additional line


My workaround in IDLE is to add a step between #6 and #7 above, where I mouse click at the desired paste location
msg363457 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2020-03-05 22:18
This is much clearer.  To expand on what I said before, inserting *anything*, such as by hitting a key, replaces a selection.  I verified that this is normal behavior, at least on Windows, with Notepad, Notepad++, and this Firefox entry box I am typing in.  So either of your steps 6 or 7 delete the still selected line, after the goto.  (And so a click is needed before 6 to stop the deletion.)  I see the continued selection as the problem.  Both Notepad and Notepad++ unselect any selection upon goto, the same as if one moved the cursor by clicking instead of goto.

I will try adding text.selection_clear() to the goto code.
msg363487 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2020-03-06 06:36
selection_clear only partially clears a selection.  That it does something is proven by selection_clear.py.  It disables selection_get.  But run the file in IDLE and when it finishes, click the tk window, select a line, click Shell, and manually repeat the last 3 lines.  selection_get is disabled again, but upon clicking the title bar of the tk window (to not affect selection in the window), the selection is still highlighted.  Further experiments showed that the insertion-deletion bug of this issue remains when using selection_own and selection_clear in IDLE.

The alternative of simulating a click on the moved insert cursor is harder by works, at least on Windows.  This also triggers a status-bar update -- see #27115.
msg363490 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2020-03-06 07:10
I am expanding this issue to include the part of #27115 that the PR will  fix. (I will also change the scope of the latter).
msg363514 - (view) Author: Dave Liptack (Dave Liptack) Date: 2020-03-06 14:33
Like goto, right-click also exhibits this behavior.  Should selection_clear also be added to right-click code?
msg363579 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2020-03-07 05:15
Agreed about right clicks.  See new issue #39885.
msg363670 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2020-03-08 18:32
New changeset 2522db11df102be3baf25ce9e816ebe8ffdb7fcc by Terry Jan Reedy in branch 'master':
bpo-39852: IDLE 'Go to line' deletes selection, updates status (GH-18801)
https://github.com/python/cpython/commit/2522db11df102be3baf25ce9e816ebe8ffdb7fcc
msg363671 - (view) Author: miss-islington (miss-islington) Date: 2020-03-08 18:49
New changeset a5e821c7269ebed6e8b4b4eee3f2247ec41a9788 by Miss Islington (bot) in branch '3.8':
bpo-39852: IDLE 'Go to line' deletes selection, updates status (GH-18801)
https://github.com/python/cpython/commit/a5e821c7269ebed6e8b4b4eee3f2247ec41a9788
msg363672 - (view) Author: miss-islington (miss-islington) Date: 2020-03-08 18:50
New changeset ec61f53243a4455f41e37a5c645e668661952c28 by Miss Islington (bot) in branch '3.7':
bpo-39852: IDLE 'Go to line' deletes selection, updates status (GH-18801)
https://github.com/python/cpython/commit/ec61f53243a4455f41e37a5c645e668661952c28
msg363691 - (view) Author: Guido van Rossum (gvanrossum) * (Python committer) Date: 2020-03-09 04:38
I have a nit on the commit message used here (and also in issue 39885). *Please* don't use this style of commit message "IDLE context menu clears selection". That phrasing sounds like it is the description of a bug. Please always use a phrasing that makes it clear what the commit/PR changes. In this case, for example, it could be "IDLE: make context menu clear selection".

I know there are projects that prefer this style. Python is not one of them. Please comply.
msg363695 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2020-03-09 06:16
Is it the temporal ambiguity (fixed by adding 'now', which is in the blurbs) or the descriptive versus command style (as with 'Returns' versus 'Return') that you do not like?  If the latter, the devguide could use augmentation.

The only relevant 'guidance' I found is this descriptive example in https://devguide.python.org/pullrequest/#making-good-commits: "the spam module is now more spammy".  This seems similar to "IDLE context menu now clears selection".  I don't see anything about commit messages in https://devguide.python.org/committing/, which seems like another likely place for such.
msg363740 - (view) Author: Guido van Rossum (gvanrossum) * (Python committer) Date: 2020-03-09 14:55
I guess it's similar to the 'return' vs. 'returns' issue, but I feel much
stronger about it here.

I would have written that as "make the spam module more spammy". Just read
a bunch of commits using e.g. `git log --oneline` to see what the
prevailing style is.
msg363770 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2020-03-09 20:46
https://github.com/python/devguide/issues/577
History
Date User Action Args
2022-04-11 14:59:27adminsetgithub: 84033
2020-03-09 20:46:53terry.reedysetmessages: + msg363770
2020-03-09 14:55:44gvanrossumsetmessages: + msg363740
2020-03-09 06:16:09terry.reedysetmessages: + msg363695
2020-03-09 04:38:39gvanrossumsetnosy: + gvanrossum
messages: + msg363691
2020-03-08 18:51:40terry.reedysetstatus: open -> closed
resolution: fixed
stage: patch review -> resolved
2020-03-08 18:50:41miss-islingtonsetmessages: + msg363672
2020-03-08 18:49:47miss-islingtonsetmessages: + msg363671
2020-03-08 18:33:01miss-islingtonsetpull_requests: + pull_request18215
2020-03-08 18:32:54miss-islingtonsetnosy: + miss-islington

pull_requests: + pull_request18214
stage: needs patch -> patch review
2020-03-08 18:32:47terry.reedysetmessages: + msg363670
2020-03-07 05:15:44terry.reedysetmessages: + msg363579
2020-03-06 14:33:17Dave Liptacksetmessages: + msg363514
2020-03-06 07:10:22terry.reedysettitle: IDLE: Goto should remove any selection -> IDLE: Goto should remove selection and update the status bar
messages: + msg363490
stage: patch review -> needs patch
2020-03-06 06:59:47terry.reedysetkeywords: + patch
stage: needs patch -> patch review
pull_requests: + pull_request18157
2020-03-06 06:36:51terry.reedysetfiles: + selection_clear.py

messages: + msg363487
2020-03-05 22:18:12terry.reedysettitle: IDLE: Copy/Paste behaves like Cut/Paste -> IDLE: Goto should remove any selection
stage: needs patch
messages: + msg363457
versions: + Python 3.7, Python 3.9
2020-03-05 16:05:13Dave Liptacksetmessages: + msg363439
2020-03-04 21:39:27terry.reedysetmessages: + msg363392
2020-03-04 18:12:17Dave Liptackcreate