-
Notifications
You must be signed in to change notification settings - Fork 284
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add config options related to Vi input mode #337
base: master
Are you sure you want to change the base?
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
# 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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: |
Going to merge this. Sorry for the delay! I'm renaming |
Rebased and merged here: #375 Thanks a lot, @antonalekseev ! |
Thanks, @jonathanslenders! Just switched from my fork back to |
This PR addresses #258 and adds couple of configuration options related to Vi input mode.
Setting
vi_start_in_nav_mode
toTrue
enablesNAVIGATION
mode on startup. The issue is that due to the current behaviour ofViState.reset()
input mode gets resetted back toINSERT
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 optionvi_keep_last_used_mode
was introduced which setsinput_mode
to the state observed before reset.vi_keep_last_used_mode
can be useful even withvi_start_in_nav_mode
set toFalse
in the case the user prefer to start inINSERT
mode but still wants to maintain the last mode he was in.In the case of
vi_keep_last_used_mode
set toFalse
andvi_start_in_nav_mode
toTrue
NAVIGATION
mode is set on every iteration the same wayINSERT
was set before this commit.Maybe interfering with the
pre_run
on 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 acceptsmode
as an argument (after this commit prompt-toolkit/python-prompt-toolkit@60b22db#diff-d95a70749837190e857489f7cbc59cdc).