-
-
Notifications
You must be signed in to change notification settings - Fork 33.1k
gh-130693: Add options of the tkinter.Text.search method: -nolinestop -all -overlap -strictlimits #130848
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Most changes to Python require a NEWS entry. Add one using the blurb_it web app or the blurb command-line tool. If this change has little impact on Python users, wait for a maintainer to apply the |
Misc/NEWS.d/next/Library/2025-03-04-17-19-26.gh-issue-130693.Kv01r8.rst
Outdated
Show resolved
Hide resolved
@ZeroIntensity Could someone please review? I think the original reviewer forgot |
Misc/NEWS.d/next/Library/2025-03-04-17-19-26.gh-issue-130693.Kv01r8.rst
Outdated
Show resolved
Hide resolved
@Wulian233 Please Review again |
I am currently pinging this PR as I have not seen a review in nearly a month. |
On it
…On Fri, May 30, 2025 at 13:22 Peter Bierma ***@***.***> wrote:
***@***.**** commented on this pull request.
------------------------------
In Misc/NEWS.d/next/Library/2025-03-04-17-19-26.gh-issue-130693.Kv01r8.rst
<#130848 (comment)>:
> @@ -0,0 +1,6 @@
+================
+Type: Enhancement
We don't need this metadata.
—
Reply to this email directly, view it on GitHub
<#130848 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/BNITW52CNI3C5F6RICJESQD3BCHTXAVCNFSM6AAAAABYKCKEFWVHI2DSMVQWIX3LMV43YUDVNRWFEZLROVSXG5CSMV3GSZLXHMZDQOBRHE2TMNRRHE>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
Done! |
It has been nearly a month. @ZeroIntensity Could you please review? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All new features need tests. Please add one to test_tkinter
.
Misc/NEWS.d/next/Library/2025-03-04-17-19-26.gh-issue-130693.Kv01r8.rst
Outdated
Show resolved
Hide resolved
Will do
…On Tue, Jun 17, 2025 at 19:07 Peter Bierma ***@***.***> wrote:
***@***.**** commented on this pull request.
All new features need tests. Please add one to test_tkinter.
------------------------------
In Misc/NEWS.d/next/Library/2025-03-04-17-19-26.gh-issue-130693.Kv01r8.rst
<#130848 (comment)>:
> @@ -0,0 +1,2 @@
+Add support for ``-nolinestop``, ``-all``, ``-overlap``, and ``-strictlimits`` options to ``tkinter.Text.search``
⬇️ Suggested change
-Add support for ``-nolinestop``, ``-all``, ``-overlap``, and ``-strictlimits`` options to ``tkinter.Text.search``
+Add support for ``-nolinestop``, ``-all``, ``-overlap``, and ``-strictlimits`` options to :meth:`tkinter.Text.search`
------------------------------
In Lib/tkinter/__init__.py
<#130848 (comment)>:
> @@ -4038,9 +4038,7 @@ def scan_dragto(self, x, y):
scan_mark."""
self.tk.call(self._w, 'scan', 'dragto', x, y)
- def search(self, pattern, index, stopindex=None,
- forwards=None, backwards=None, exact=None,
- regexp=None, nocase=None, count=None, elide=None):
+ def search(self, pattern, index, stopindex=None, forwards=None, backwards=None, exact=None, regexp=None, nocase=None, count=None, elide=None, nolinestop=None, all=None, overlap=None, strictlimits=None):
Please change it back to the old formatting.
------------------------------
In Lib/tkinter/__init__.py
<#130848 (comment)>:
> +
+
Stray newline changes:
⬇️ Suggested change
-
-
—
Reply to this email directly, view it on GitHub
<#130848 (review)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/BNITW5Z32DYZL5OQEMOCKLL3EAK2TAVCNFSM6AAAAABYKCKEFWVHI2DSMVQWIX3LMV43YUDVNRWFEZLROVSXG5CSMV3GSZLXHMZDSMZVG4YTGOBSG4>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
Co-authored-by: Peter Bierma <[email protected]>
Co-authored-by: Peter Bierma <[email protected]>
I updated the branch as it has been a while since this PR has been opened |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for your update.
Misc/NEWS.d/next/Library/2025-03-04-17-19-26.gh-issue-130693.Kv01r8.rst
Outdated
Show resolved
Hide resolved
Gentle ping |
^^^^^^^^^^^^^^ | ||
AttributeError: 'Container' object has no attribute 'area'. Did you mean: 'inner.area'? | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unrelated change.
'Another line.\n' | ||
'Yet another line.') | ||
|
||
result = text.search('line', '1.0', 'end', nolinestop=True, regexp=True) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why regexp=True
if it is not a regexp?
It would be nice for each option to call search()
with the same arguments, but with and without that option (the results should be different). So we will see that it works.
self.assertGreater(len(overlap_res), len(all_res)) | ||
|
||
# Check that overlap actually finds overlapping matches | ||
self.assertIn('2.0', overlap_res_strs) | ||
self.assertIn('2.2', overlap_res_strs) | ||
self.assertIn('2.4', overlap_res_strs) | ||
self.assertNotIn('2.2', all_res_strs) | ||
|
||
# Ensure all results are valid text indices | ||
for i in overlap_res: | ||
self.assertRegex(str(i), r'^\d+\.\d+$') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can't we simply test self.assertEqual(overlap_res_strs, ['1.0', '1.2', ...])
? And the same for non-overlapped search. The example should perhaps be smaller.
|
||
(Contributed by Pablo Galindo and László Kiss Kollár in :gh:`135953`.) | ||
|
||
======= |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unrelated change.
Add options -nolinestop, -all, -overlap, and -strictlimits to the search function of the text class of tkinter.
Fixes #130693
Closes #130693
Tested against
And test passed. Result:
Also tested against a custom test file:
Which returns:
Indicating that the new features are functioning correctly