FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

gh-57795: IDLE: Enter the selected text when opening the "Replace" dialog by ZackerySpytz · Pull Request #17593 · python/cpython · GitHub

Repository navigation

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .py  (1) .rst  (1) All 2 file types selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
23 changes: 7 additions & 16 deletions Lib/idlelib/replace.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ def replace(text, insert_tags=None):
if not hasattr(engine, "_replacedialog"):
engine._replacedialog = ReplaceDialog(root, engine)
dialog = engine._replacedialog
dialog.open(text, insert_tags=insert_tags)
searchphrase = text.get("sel.first", "sel.last")
dialog.open(text, searchphrase, insert_tags=insert_tags)


class ReplaceDialog(SearchDialogBase):
Expand All @@ -51,27 +52,17 @@ def __init__(self, root, engine):
self.replvar = StringVar(root)
self.insert_tags = None

def open(self, text, insert_tags=None):
def open(self, text, searchphrase=None, *, insert_tags=None):
"""Make dialog visible on top of others and ready to use.

Also, highlight the currently selected text and set the
search to include the current selection (self.ok).
Also, set the search to include the current selection
(self.ok).

Args:
text: Text widget being searched.
searchphrase: String phrase to search.
"""
SearchDialogBase.open(self, text)
try:
first = text.index("sel.first")
except TclError:
first = None
try:
last = text.index("sel.last")
except TclError:
last = None
first = first or text.index("insert")
last = last or first
self.show_hit(first, last)
SearchDialogBase.open(self, text, searchphrase)
self.ok = True
self.insert_tags = insert_tags

Expand Down
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Enter the selected text when opening the "Replace" dialog.

Back | FazBrowse Home | New Git URL