Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork252
Corrected cursor positioning on inputs with full-width (2 column) characters#817
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Changes fromall commits
File 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 |
|---|---|---|
| @@ -19,6 +19,8 @@ | ||
| from bpython._py3compat import PythonLexer | ||
| from pygments.formatters import TerminalFormatter | ||
| from wcwidth import wcswidth | ||
| import blessings | ||
| import curtsies | ||
| @@ -1359,7 +1361,11 @@ def display_line_with_prompt(self): | ||
| @property | ||
| def current_cursor_line_without_suggestion(self): | ||
| """ | ||
| Current line, either output/input or Python prompt + code | ||
| :returns: FmtStr | ||
| """ | ||
| value = self.current_output_line + ( | ||
| "" if self.coderunner.running else self.display_line_with_prompt | ||
| ) | ||
| @@ -1556,7 +1562,8 @@ def move_screen_up(current_line_start_row): | ||
| if self.stdin.has_focus: | ||
| cursor_row, cursor_column = divmod( | ||
| wcswidth(self.current_stdouterr_line) | ||
| + wcswidth(self.stdin.current_line[: self.stdin.cursor_offset]), | ||
| width, | ||
| ) | ||
| assert cursor_column >= 0, cursor_column | ||
| @@ -1574,12 +1581,12 @@ def move_screen_up(current_line_start_row): | ||
| len(self.current_line), | ||
| self.cursor_offset, | ||
| ) | ||
| else: # Common case for determining cursor position | ||
| cursor_row, cursor_column = divmod( | ||
| ( | ||
| wcswidth(self.current_cursor_line_without_suggestion.s) | ||
| -wcswidth(self.current_line) | ||
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. What's the distinction here between the wcswidth and .width, are some of these FmtStrs and some of them plain strs? (and if it's not clear, could you add comments to the definitions or initialization lines?) | ||
| +wcswidth(self.current_line[: self.cursor_offset]) | ||
| ), | ||
| width, | ||
| ) | ||