zimfw / minimal

A minimal fork of subnixr's minimal prompt theme.
GNU General Public License v3.0
8 stars 3 forks source link

last character of path is colored green after tab-completion #7

Closed tjex closed 1 year ago

tjex commented 1 year ago

Describe the bug
When tab completing a path, and leaving the end of the path string with space, the last character becomes green. ie:

  1. cd some/pa
  2. tab (completes to some/path/)
  3. space
  4. end string result in prompt 'cd some/path <cursor>'

Steps to reproduce
The fist 4 steps restart the shell with a clean installation of Zim in a temporary directory. Use exec zsh when restarting the terminal or restarting the shell is needed.

  1. cd ${$(mktemp -d):A}
  2. ZDOTDIR=${PWD} HOME=${PWD} ZIM_HOME=${PWD}/.zim exec zsh
  3. curl -fsSL https://raw.githubusercontent.com/zimfw/install/master/install.zsh | zsh
  4. exec zsh
  5. add zmodule minimal to .zimrc
  6. run zimfw update
  7. despite installing the minimal theme in the temp config, the theme would not activate after running exec zsh... I'm not sure why. Happy to try again if needed.

Current behavior
When tab completing a path, and leaving the end of the path string with space, the last character becomes green. ie:

  1. cd some/path
  2. tab
  3. space

Expected behavior
The last character of the path string stays white, like the rest of the string.

Screenshots

Described behaviour and tab completion / space process with :

minimal theme

Screen Shot 2023-02-26 at 20 56 06

oblong theme

Screen Shot 2023-02-26 at 19 51 58

no theme

Screen Shot 2023-02-26 at 19 52 25

temp / minimal install Screen Shot 2023-02-26 at 20 32 46

zimfw info

zimfw version:        1.11.3 (built at 2023-02-26 00:43:41 UTC, previous commit is 6a24459)
OSTYPE:               darwin21.0
TERM:                 xterm-kitty
TERM_PROGRAM:         
TERM_PROGRAM_VERSION: 
ZIM_HOME:             /Users/tillman/.config/zsh/zim
ZSH_VERSION:          5.8.1

Additional context
This is my .zimrc

# Start configuration added by Zim install {{{
zmodule environment
zmodule git
zmodule input
zmodule utility

#
# Prompt
#

# zmodule duration-info # gets duration info for prompt
zmodule git-info # formats git info for prompt
zmodule prompt-pwd # formats cwd for prompt
zmodule Aloxaf/fzf-tab # tab search with fzf
zmodule jeffreytse/zsh-vi-mode # vim bindings in terminal
zmodule fzf

# Themes 
# zmodule s1ck94
zmodule minimal

#
# Completion
#

zmodule zsh-users/zsh-completions --fpath src
zmodule completion

#
# Modules that must be initialized last
#

# zsh-users/zsh-syntax-highlighting must be sourced after completion
zmodule zsh-users/zsh-syntax-highlighting
# }}}
ericbn commented 1 year ago

Could not reproduce with a new installation of Zim replacing duration-info + git-info + asciiship by git-info + prompt-pwd + minimal.

Also could not reproduce with a new installation of Zim using your .zimrc, because TAB opens fzf and then SPACE does not select the completion. Even if doing TAB ENTER SPACE, I still cannot see the last character turn green.

Maybe this is related to one of the plugins you're using? Have you tried disabling one by one?

tjex commented 1 year ago

hmm damn. thanks for checking. I did try disabling what the main culprits should probably be (completion / syntax highlighting). But will have a more thorough go.

tjex commented 1 year ago

so I looked further and I've got new hints, but no answers... I uninstalled all plugins except the minimal theme (I'm only using zim and no external plugins).

It looks like the text is inheriting the color of the lambda symbol, which is being set dependent on whether a command was executed with/without fail.

Screen Shot 2023-03-02 at 15 27 28

The thing is that I was using the s1ck94 theme, which also took the color of a successful / failed command, and it did not color the text.

I'll keep looking, but it seems that it's not to do with any other zim / zsh plugin. This occurs in kitty and iterm.

maybe its a macos thing.

PatTheMav commented 1 year ago

I guess this might be due to the colour for the prompt character never being reset via %f:

https://github.com/zimfw/minimal/blob/08fcfda81af4d229f71270dc77dce28346311de5/minimal.zsh-theme#L54

The colour is set, the user character is printed, but colour is not reset. I haven't looked into it, but this suggests that colour in prompts is scoped - as in each %F creates a colour scope and the caret character gets its own colour scope to be printed in grey, but once it uses %f it exits its colour scope and we're back in the scope of the user character (green/red respectively in the above example).

Could you try replacing %{\E[0m%} with %f and see if that fixes the issue?

ericbn commented 1 year ago

@PatTheMav is correct. Just fixed that. The %{\E[0m%} is needed to clear the mode previously set by %{\E[${MNML_BGJOB_MODE}m%}, but that was not clearing the foreground color set by %F{%(?.${MNML_OK_COLOR}.${MNML_ERR_COLOR})}. Added the extra %f.

Good catch @tjex!

tjex commented 1 year ago

Could you try replacing %{\E[0m%} with %f and see if that fixes the issue?

Yup! That did it :~) Thank you and very happy to have caught it @ericbn !