Skip to content
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

Revise the vi mode indicator to ❮ for non-insert modes #140

Merged
merged 11 commits into from
Feb 19, 2019

Conversation

codesections
Copy link
Contributor

@codesections codesections commented Feb 7, 2019

related: #139


This PR changes the default behavior of the prompt in vi mode, as discussed in #139.

Previously, the prompt retained the fish shell's default mode indicator: it would print [I], [N], or [V] to indicate whether the user was in insert, normal, or visual mode.

After this commit, the prompt will flip to whenever the user is not in insert mode. This matches the behavior of the zsh version of Pure.

The user can restore the prior functionality by setting the pure_reverse_prompt_symbol_in_vimode variable to false in their conf.d/pure.fish file.

Copy link
Member

@edouard-lopez edouard-lopez left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR 👍

I reviewed your code and requested some changes.
Feel free to ask for clarification.

Could you add automated tests in order to validate your feature before merge:

  1. verify the variable is correctly set in conf.d/pure.fish via _tests/pure.test.fish
  2. verify the behavior is working as expected when configuration is true/false, see _tests/pure_prompt_vimode.test.fish

functions/_pure_prompt_symbol.fish Outdated Show resolved Hide resolved
@@ -1,3 +1,6 @@
function _pure_prompt_vimode
echo (fish_default_mode_prompt)
set --local reverse_symbol_instead_of_default_mode_prompt $pure_reverse_prompt_symbol_in_vimode
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here, no need for a proxy variable, use the original one directly, the code will be easier to read and maintain 👍

functions/_pure_prompt_vimode.fish Outdated Show resolved Hide resolved
if test reverse_symbol_instead_of_default_mode_prompt
# Do nothing if not in vi mode
if test "$fish_key_bindings" = "fish_vi_key_bindings"
or test "$fish_key_bindings" = "fish_hybrid_key_bindings"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should use string match and glob/regex to test the key_binding mode

if test (string match fish_{vi,hybrid}_key_bindings $fish_key_bindings)

or to be more explicit:

set --local is_vi_mode (string match fish_{vi,hybrid}_key_bindings $fish_key_bindings)
if test is_vi_mode

functions/_pure_prompt_symbol.fish Outdated Show resolved Hide resolved
@codesections
Copy link
Contributor Author

Thanks for the comments.

I revised the PR to address your comments on the code, and took all your suggestions.

With regards to testing, I added one simple test for the config variable. However, both on my local machine and the CI checks, the tests are not providing meaningful feedback—I am getting fish: 'end' outside of a block instead of results based on whether the test passed or failed. (This is true even if I add tests that should fail.)

Given that I'm not able to see if the test is passing or not, I'm not particularly comfortable with writing a more complex test (especially since I'm not familiar with fish scripting or with whatever this test environment is).

If anyone else is more familiar with testing/has a setup under which the tests run, they should feel free to add an additional test for the rest of the functionality.

Copy link
Member

@edouard-lopez edouard-lopez left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, that's look good.
Kudos for trying to implement tests! 🙏

I'm marking as requesting changes as I did the review on my phone and will work on it to add the tests.

The error you described in the test might be due to fishtape, that had a new major release, and the way we install it.

tests/_pure.test.fish Outdated Show resolved Hide resolved
conf.d/pure.fish Outdated Show resolved Hide resolved
codesections and others added 8 commits February 19, 2019 13:17
This commit changes the default behavior of the prompt in vi mode.

Previously, the prompt retained the fish shell's default mode indicator:
it would print `[I]`, `[N]`, or `[V]` to indicate whether the user was
in insert, normal, or visual mode.

After this commit, the prompt will flip to `❮` whenever the user is not
in insert mode.  This matches the behavior of the zsh version of Pure.

The user can restore the prior functionality by setting the
`pure_reverse_prompt_symbol_in_vimode` variable to `false` in their
conf.d/pure.fish file.
@edouard-lopez
Copy link
Member

@codesections I committed some change, could you test it's the expected behaviour?

@codesections
Copy link
Contributor Author

Yes, it seems to work great. Thanks!

@edouard-lopez edouard-lopez merged commit 563ccd2 into pure-fish:master Feb 19, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants