Repository navigation
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
8b2f533
68abcab
f073ae1
d799e34
3c9c567
c515a21
8eebebf
cf1b8ff
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 | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -457,6 +457,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
+487
to
+488
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_not_colorized_test_class | ||||||||||
| class TestErrorMessages(TestCase): | ||||||||||
|
|
||||||||||
| 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.
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.