Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 35.2k
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?
Uh oh!
There was an error while loading. Please reload this page.
Changes from all commits
678eefd853cb8c99023b2e6d27d99f54090140faf1c8d17590a25f0bFile filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
| @@ -358,6 +358,41 @@ 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 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. These only exercise | ||||||||||
| # See https://github.com/python/cpython/issues/146044. | ||||||||||
| 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([])) | ||||||||||
| buf = "foo.bar(baz) qux" | ||||||||||
| reader.buffer = list(buf) | ||||||||||
| reader.pos = buf.index(")") + 1 | ||||||||||
| 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
+388
to
+389
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
| ||||||||||
| def test_bow_ws_with_newlines(self): | ||||||||||
| reader = prepare_reader(prepare_console([])) | ||||||||||
| reader.buffer = list("foo\nbar") | ||||||||||
| reader.pos = len(reader.buffer) | ||||||||||
| self.assertEqual(reader.bow_ws(), 4) | ||||||||||
| @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. |
Uh oh!
There was an error while loading. Please reload this page.
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.
We already use
c.isspace()for whitespace inkill_linejust above the caller incommands.py. Why hardcode" \n\t"here twice instead?b[p].isspace()would be consistent and also cover\r/\f/\v.