-
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.
vi: Fix recalling lines starting with whitespace (re: 161139d)
@jghub reports: > if for some reason a command is entered with leading whitespace, > the leading whitespace is preserved in the history file (in > ksh93u+, too). such commands can be recalled from history in 93u+ > without problem, both, in vi and emacs mode. > > but in 93u+m such entries are simply ignored when using vi-mode > (set -o vi), i.e. the k and j commands skip over such entries. > emacs mode still works just fine. Analysis: the blankline() function in vi.c and emacs.c is used to check for whitespace up to the cursor position. This is used for tab completion and fullscreen editor invocation, where that is okay, and for history recall, where that should be checking the entire line instead. In emacs.c this was not really a problem because arrowing up (or ^P) positions the cursor to the end of the line anyway. But in vi, arrowing up (or 'k') positions the cursor at the beginning. src/cmd/ksh93/edit/vi.c: - Amend blankline() with an 'uptocursor' argument. If nonzero, it checks the current line for whitespace up to the cursor position, otherwise it checks the entire line. - Pass uptocursor==0 to blankline() for history recall and 1 for tab completion. src/cmd/ksh93/edit/emacs.c: - Apply the same change here for consistency, even though it's perhaps not really necessary. If ever a form of recall is added that doesn't position the cursor at the end, then that won't introduce this bug there. Thanks to @pghvlaans for input into the fix. Resolves: #799
- Loading branch information
Showing
5 changed files
with
34 additions
and
16 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
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