GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | |||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | |||||||||||||||||||
GeezerVison is showing github.com — gh-133710: Enhance pyrepl auto-indent by tanloong · Pull Request #140710 · python/cpython Conversation
|
| # update stack | ||
| if char in "\"'" and (i == 0 or buffer[i - 1] != "\\"): | ||
| if str_delims and str_delims[-1] == char: | ||
| str_delims.pop() | ||
| else: | ||
| str_delims.append(char) |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
You'd also have to add f-string and t-string support to that. So you'd have to parse braces, but only if they're not escaped and they're in the right string prefixes.
At this stage, I'm afraid this function will balloon into a poor reimplementation of a decent chunk of the tokenizer. But we already use the tokenizer properly for syntax highlighting. We even have specific functionality to discover unterminated multiline strings.
Look at _pyrepl.utils and think about how that could be reused here instead of the manual approach.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your review! I have made the change to rely on _pyrepl.utils.gen_colors for a tokenizer-based parsing of strings and comments.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
This PR is stale because it has been open for 30 days with no activity. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
There was an error while loading. Please reload this page.