Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit712afab

Browse files
ZackerySpytzserwyserhiy-storchaka
authored
gh-57795: IDLE: Enter the selected text when opening the "Replace" dialog (GH-17593)
Co-authored-by: Roger Serwy <roger.serwy@gmail.com>Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
1 parent1ddd773 commit712afab

File tree

2 files changed

+8
-16
lines changed

2 files changed

+8
-16
lines changed

‎Lib/idlelib/replace.py

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ def replace(text, insert_tags=None):
2525
ifnothasattr(engine,"_replacedialog"):
2626
engine._replacedialog=ReplaceDialog(root,engine)
2727
dialog=engine._replacedialog
28-
dialog.open(text,insert_tags=insert_tags)
28+
searchphrase=text.get("sel.first","sel.last")
29+
dialog.open(text,searchphrase,insert_tags=insert_tags)
2930

3031

3132
classReplaceDialog(SearchDialogBase):
@@ -51,27 +52,17 @@ def __init__(self, root, engine):
5152
self.replvar=StringVar(root)
5253
self.insert_tags=None
5354

54-
defopen(self,text,insert_tags=None):
55+
defopen(self,text,searchphrase=None,*,insert_tags=None):
5556
"""Make dialog visible on top of others and ready to use.
5657
57-
Also,highlight thecurrently selected text and set the
58-
search to include the current selection(self.ok).
58+
Also,set thesearch to include the current selection
59+
(self.ok).
5960
6061
Args:
6162
text: Text widget being searched.
63+
searchphrase: String phrase to search.
6264
"""
63-
SearchDialogBase.open(self,text)
64-
try:
65-
first=text.index("sel.first")
66-
exceptTclError:
67-
first=None
68-
try:
69-
last=text.index("sel.last")
70-
exceptTclError:
71-
last=None
72-
first=firstortext.index("insert")
73-
last=lastorfirst
74-
self.show_hit(first,last)
65+
SearchDialogBase.open(self,text,searchphrase)
7566
self.ok=True
7667
self.insert_tags=insert_tags
7768

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Enter the selected text when opening the "Replace" dialog.

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp