Skip to content

Commit 2522db1

Browse files
authored
bpo-39852: IDLE 'Go to line' deletes selection, updates status (pythonGH-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.
1 parent c580981 commit 2522db1

File tree

5 files changed

+31
-16
lines changed

5 files changed

+31
-16
lines changed

Doc/library/idle.rst

+3-1
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,9 @@ Replace...
142142
Open a search-and-replace dialog.
143143

144144
Go to Line
145-
Move cursor to the line number requested and make that line visible.
145+
Move the cursor to the beginning of the line requested and make that
146+
line visible. A request past the end of the file goes to the end.
147+
Clear any selection and update the line and column status.
146148

147149
Show Completions
148150
Open a scrollable list allowing selection of keywords and attributes. See

Lib/idlelib/NEWS.txt

+3
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@ Released on 2020-10-05?
33
======================================
44

55

6+
bpo-39852: Edit "Go to line" now clears any selection, preventing
7+
accidental deletion. It also updates Ln and Col on the status bar.
8+
69
bpo-39781: Selecting code context lines no longer causes a jump.
710

811
bpo-39663: Add tests for pyparse find_good_parse_start().

Lib/idlelib/editor.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -678,8 +678,11 @@ def goto_line_event(self, event):
678678
if lineno <= 0:
679679
text.bell()
680680
return "break"
681-
text.mark_set("insert", "%d.0" % lineno)
681+
682+
text.tag_remove("sel", "1.0", "end")
683+
text.mark_set("insert", f'{lineno}.0')
682684
text.see("insert")
685+
self.set_line_and_column()
683686
return "break"
684687

685688
def open_module(self):

Lib/idlelib/help.html

+19-14
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<html xmlns="http://www.w3.org/1999/xhtml">
55
<head>
66
<meta charset="utf-8" />
7-
<title>IDLE &#8212; Python 3.9.0a1 documentation</title>
7+
<title>IDLE &#8212; Python 3.9.0a4 documentation</title>
88
<link rel="stylesheet" href="../_static/pydoctheme.css" type="text/css" />
99
<link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
1010

@@ -17,7 +17,7 @@
1717
<script type="text/javascript" src="../_static/sidebar.js"></script>
1818

1919
<link rel="search" type="application/opensearchdescription+xml"
20-
title="Search within Python 3.9.0a1 documentation"
20+
title="Search within Python 3.9.0a4 documentation"
2121
href="../_static/opensearch.xml"/>
2222
<link rel="author" title="About these documents" href="../about.html" />
2323
<link rel="index" title="Index" href="../genindex.html" />
@@ -71,7 +71,7 @@ <h3>Navigation</h3>
7171

7272

7373
<li>
74-
<a href="../index.html">3.9.0a1 Documentation</a> &#187;
74+
<a href="../index.html">3.9.0a4 Documentation</a> &#187;
7575
</li>
7676

7777
<li class="nav-item nav-item-1"><a href="index.html" >The Python Standard Library</a> &#187;</li>
@@ -197,7 +197,9 @@ <h3>Edit menu (Shell and Editor)<a class="headerlink" href="#edit-menu-shell-and
197197
</dd>
198198
<dt>Replace…</dt><dd><p>Open a search-and-replace dialog.</p>
199199
</dd>
200-
<dt>Go to Line</dt><dd><p>Move cursor to the line number requested and make that line visible.</p>
200+
<dt>Go to Line</dt><dd><p>Move the cursor to the beginning of the line requested and make that
201+
line visible. A request past the end of the file goes to the end.
202+
Clear any selection and update the line and column status.</p>
201203
</dd>
202204
<dt>Show Completions</dt><dd><p>Open a scrollable list allowing selection of keywords and attributes. See
203205
<a class="reference internal" href="#completions"><span class="std std-ref">Completions</span></a> in the Editing and navigation section below.</p>
@@ -635,17 +637,20 @@ <h3>Startup failure<a class="headerlink" href="#startup-failure" title="Permalin
635637
clash, or cannot or does not want to run as admin, it might be easiest to
636638
completely remove Python and start over.</p>
637639
<p>A zombie pythonw.exe process could be a problem. On Windows, use Task
638-
Manager to detect and stop one. Sometimes a restart initiated by a program
639-
crash or Keyboard Interrupt (control-C) may fail to connect. Dismissing
640-
the error box or Restart Shell on the Shell menu may fix a temporary problem.</p>
640+
Manager to check for one and stop it if there is. Sometimes a restart
641+
initiated by a program crash or Keyboard Interrupt (control-C) may fail
642+
to connect. Dismissing the error box or using Restart Shell on the Shell
643+
menu may fix a temporary problem.</p>
641644
<p>When IDLE first starts, it attempts to read user configuration files in
642645
<code class="docutils literal notranslate"><span class="pre">~/.idlerc/</span></code> (~ is one’s home directory). If there is a problem, an error
643646
message should be displayed. Leaving aside random disk glitches, this can
644-
be prevented by never editing the files by hand, using the configuration
645-
dialog, under Options, instead Options. Once it happens, the solution may
646-
be to delete one or more of the configuration files.</p>
647+
be prevented by never editing the files by hand. Instead, use the
648+
configuration dialog, under Options. Once there is an error in a user
649+
configuration file, the best solution may be to delete it and start over
650+
with the settings dialog.</p>
647651
<p>If IDLE quits with no message, and it was not started from a console, try
648-
starting from a console (<code class="docutils literal notranslate"><span class="pre">python</span> <span class="pre">-m</span> <span class="pre">idlelib</span></code>) and see if a message appears.</p>
652+
starting it from a console or terminal (<code class="docutils literal notranslate"><span class="pre">python</span> <span class="pre">-m</span> <span class="pre">idlelib</span></code>) and see if
653+
this results in an error message.</p>
649654
</div>
650655
<div class="section" id="running-user-code">
651656
<h3>Running user code<a class="headerlink" href="#running-user-code" title="Permalink to this headline"></a></h3>
@@ -930,7 +935,7 @@ <h3>Navigation</h3>
930935

931936

932937
<li>
933-
<a href="../index.html">3.9.0a1 Documentation</a> &#187;
938+
<a href="../index.html">3.9.0a4 Documentation</a> &#187;
934939
</li>
935940

936941
<li class="nav-item nav-item-1"><a href="index.html" >The Python Standard Library</a> &#187;</li>
@@ -953,15 +958,15 @@ <h3>Navigation</h3>
953958
</ul>
954959
</div>
955960
<div class="footer">
956-
&copy; <a href="../copyright.html">Copyright</a> 2001-2019, Python Software Foundation.
961+
&copy; <a href="../copyright.html">Copyright</a> 2001-2020, Python Software Foundation.
957962
<br />
958963

959964
The Python Software Foundation is a non-profit corporation.
960965
<a href="https://www.python.org/psf/donations/">Please donate.</a>
961966
<br />
962967
<br />
963968

964-
Last updated on Nov 24, 2019.
969+
Last updated on Mar 07, 2020.
965970
<a href="https://docs.python.org/3/bugs.html">Found a bug</a>?
966971
<br />
967972

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Edit "Go to line" now clears any selection, preventing accidental deletion.
2+
It also updates Ln and Col on the status bar.

0 commit comments

Comments
 (0)