-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix multiple bugs in emacs and vi (#565)
This (somewhat expanded) commit addresses three behaviors in vi mode and two behaviors in emacs mode: - In vi mode, calling v from a completely empty line rings the bell rather than calling the full editor. - In vi mode, calling v from a spaces-only line results in an "invalid range" hist error, and the editor fails to open. - In emacs mode, calling the full editor saves the current contents of the command line to the history file without a new line. (issue #563) - In both editing modes, navigating to a null or empty history line displays an empty line onscreen. A summary of the fixes: The hist builtin seems to expect either a new line with the cursor in position 0 or a line with at least one non-space character; in all cases, the line should conclude with \n and \0: - In vi.c, set the position to 0, refresh and insert \n if command mode v is called from an empty line or a line made up entirely of spaces. This enables hist to call the full editor with an appropriate range. - In emacs.c, add \n and \0 to drawbuff before calling ed_fulledit (but after checking its failure conditions). This prevents the insertion of null history items for both empty and non-empty lines. Because lines composed entirely of spaces can cause the following prompt to be offset, clear such lines as well. Other shells, including mksh, oksh, bash and yash, also save empty history lines. However, actually displaying these blank lines when navigating using e.g. the arrow keys (as is the case in ksh, mksh and oksh) is unhelpful: - In vi.c and emacs.c, check the history line for non-space characters. If the line is completely empty, resend the appropriate key provided that doing so would not go beyond the confines of the first and last history lines. This effectively skips empty lines when navigating. Another bugfix: Attempting to tab-complete an alias or $PATH item containing wide characters before the first normal-width character has been entered fails in both vi and emacs modes (see #532). The mechanism for finding empty lines does not recognize wide non-space characters as non-space characters, so lines with nothing but wide characters always fail to reach the completion stage. When SHOPT_MULTIBYTE, use !iswspace rather than !isspace to detect wide characters. (bug introduced by a874586) Resolves: #532 Resolves: #563
- Loading branch information
Showing
3 changed files
with
104 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters