Add config options related to Vi input mode#337
Open
antonalekseev wants to merge 1 commit intoprompt-toolkit:mainfrom
Open
Add config options related to Vi input mode#337antonalekseev wants to merge 1 commit intoprompt-toolkit:mainfrom
antonalekseev wants to merge 1 commit intoprompt-toolkit:mainfrom
Conversation
Setting `vi_start_in_nav_mode` to `True` enables `NAVIGATION` mode on startup. The issue is that due to the current behaviour of `ViState.reset()` input mode gets resetted back to `INSERT` on the every iteration of the main loop. In order to at one hand to provide the user with desired behaviour and on the other hand doesn't introduce breaking changes the other option `vi_keep_last_used_mode` was introduced which sets `input_mode` to the state observed before reset. `vi_keep_last_used_mode` can be useful even with `vi_start_in_nav_mode` set to `False` in the case the user prefer to start in `INSERT` mode but still wants to maintain the last mode he was in. In the case of `vi_keep_last_used_mode` set to `False` and `vi_start_in_nav_mode` to `True` `NAVIGATION` mode is set on every iteration the same way `INSERT` was set before this commit. Fixes prompt-toolkit#258.
8cf908a to
6b8c3fc
Compare
mkatychev
reviewed
Apr 19, 2020
| # Capture the current input_mode in order to restore it after reset, | ||
| # for ViState.reset() sets it to InputMode.INSERT unconditionally and | ||
| # doesn't accept any arguments despite the docstring says otherwise. | ||
| def pre_run(last_input_mode=self.app.vi_state.input_mode): |
There was a problem hiding this comment.
Suggested change
| def pre_run(last_input_mode=self.app.vi_state.input_mode): | |
| def pre_run(last_input_mode=self.app.vi_state.input_mode) -> None: |
Member
|
Going to merge this. Sorry for the delay! I'm renaming |
Member
|
Rebased and merged here: #375 Thanks a lot, @antonalekseev ! |
Contributor
Author
|
Thanks, @jonathanslenders! Just switched from my fork back to |
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR addresses #258 and adds couple of configuration options related to Vi input mode.
Setting
vi_start_in_nav_modetoTrueenablesNAVIGATIONmode on startup. The issue is that due to the current behaviour ofViState.reset()input mode gets resetted back toINSERTon the every iteration of the main loop. In order to at one hand to provide the user with desired behaviour and on the other hand doesn't introduce breaking changes the other optionvi_keep_last_used_modewas introduced which setsinput_modeto the state observed before reset.vi_keep_last_used_modecan be useful even withvi_start_in_nav_modeset toFalsein the case the user prefer to start inINSERTmode but still wants to maintain the last mode he was in.In the case of
vi_keep_last_used_modeset toFalseandvi_start_in_nav_modetoTrueNAVIGATIONmode is set on every iteration the same wayINSERTwas set before this commit.Maybe interfering with the
pre_runon the main loop is not the best option but I don't see any other way to set input mode after reset forViState.reset()no longer acceptsmodeas an argument (after this commit prompt-toolkit/python-prompt-toolkit@60b22db#diff-d95a70749837190e857489f7cbc59cdc).