-
-
Notifications
You must be signed in to change notification settings - Fork 34.3k
gh-146044: Fix ctrl-w (unix-word-rubout) to use whitespace word boundaries #146174
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?
Changes from all commits
678eefd
853cb8c
99023b2
e6d27d9
9f54090
140faf1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -358,6 +358,34 @@ def test_setpos_from_xy_for_non_printing_char(self): | |||||||||
| reader.setpos_from_xy(8, 0) | ||||||||||
| self.assertEqual(reader.pos, 7) | ||||||||||
|
|
||||||||||
| def test_bow_ws_stops_at_whitespace(self): | ||||||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Where are the existing tests for bow()? id there are some, please put those tests next to them |
||||||||||
| # See https://github.com/python/cpython/issues/146044 | ||||||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||
| reader = prepare_reader(prepare_console([])) | ||||||||||
| reader.buffer = list("foo.bar baz") | ||||||||||
| reader.pos = len(reader.buffer) | ||||||||||
| self.assertEqual(reader.bow_ws(), 8) | ||||||||||
|
|
||||||||||
| def test_bow_ws_includes_punctuation_in_word(self): | ||||||||||
| reader = prepare_reader(prepare_console([])) | ||||||||||
| reader.buffer = list("foo.bar(baz) qux") | ||||||||||
| reader.pos = 12 | ||||||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Use the index() method to get the index of ) |
||||||||||
| self.assertEqual(reader.bow_ws(), 0) | ||||||||||
|
|
||||||||||
| def test_bow_vs_bow_ws(self): | ||||||||||
| reader = prepare_reader(prepare_console([])) | ||||||||||
| reader.buffer = list("foo.bar") | ||||||||||
| reader.pos = len(reader.buffer) | ||||||||||
| # bow() stops at '.' so we return the index of 'b' in "bar" | ||||||||||
| self.assertEqual(reader.bow(), 4) | ||||||||||
| # bow_ws() treats entire "foo.bar" as one word | ||||||||||
| self.assertEqual(reader.bow_ws(), 0) | ||||||||||
|
|
||||||||||
| def test_bow_ws_with_tabs(self): | ||||||||||
| reader = prepare_reader(prepare_console([])) | ||||||||||
| reader.buffer = list("foo\tbar") | ||||||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add tests with \n and ensure that you also properly jump lines. |
||||||||||
| reader.pos = len(reader.buffer) | ||||||||||
| self.assertEqual(reader.bow_ws(), 4) | ||||||||||
|
|
||||||||||
|
Comment on lines
+387
to
+388
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||
| @force_colorized_test_class | ||||||||||
| class TestReaderInColor(ScreenEqualMixin, TestCase): | ||||||||||
| def test_syntax_highlighting_basic(self): | ||||||||||
|
|
||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| Fix ``unix-word-rubout`` (Ctrl-W) in the REPL to use whitespace-only word | ||
| boundaries, matching behavior of the basic REPL. Previously it used | ||
| syntax-table boundaries which treated punctuation as word separators. |
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.
My suggestion was to remove the ref to the issue