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

Restore prompt_subst setopt when rendering prompt #231

Merged
merged 1 commit into from
Sep 20, 2016

Conversation

mafredri
Copy link
Collaborator

@mafredri mafredri commented Sep 17, 2016

We store the user setting for prompt_subst before changing it in the local scope of prompt_pure_preprompt_render. This allows us to restore it when we render the real prompt (PS1) through zle .redraw-prompt.

Fixes #230.


The was also one other way to fix this, to use anonymous functions in both places where we print the preprompt. Either solution is good imo, anonymous perhaps slightly cleaner (and doesn't depend on zsh/parameter) but I decided to go with this approach, mainly for the reason that I don't know when anonymous functions were introduced into zsh.

Example of anonymous version:

    if [[ "$1" == "precmd" ]]; then
        () {
            setopt local_options no_prompt_subst
            print -P "\n${preprompt}"
        }
    else
        ...
        # modify previous preprompt
        () {
            setopt local_options no_prompt_subst
            print -Pn "${clr_prev_preprompt}\e[${lines}A\e[${COLUMNS}D${preprompt}${clr}\n"
        }

We store the user setting for `prompt_subst` before changing it in the
local scope of `prompt_pure_preprompt_render`. This allows us to restore
it when we render the real prompt (`PS1`) through `zle .redraw-prompt`.

Fixes sindresorhus#230.
@mafredri mafredri merged commit 5ccc336 into sindresorhus:master Sep 20, 2016
@mafredri mafredri deleted the fix-prompt-subst branch September 20, 2016 13:56
kutsan pushed a commit to kutsan/pure that referenced this pull request Jun 19, 2023
We store the user setting for `prompt_subst` before changing it in the
local scope of `prompt_pure_preprompt_render`. This allows us to restore
it when we render the real prompt (`PS1`) through `zle .redraw-prompt`.

Fixes sindresorhus#230.
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.

${editor_info[keymap]} would be sometimes popped up
2 participants