Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
O
oh-my-zsh
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
github
oh-my-zsh
Commits
cc991321
Unverified
Commit
cc991321
authored
Mar 31, 2023
by
Marc Cornellà
Committed by
GitHub
Mar 31, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix(vi-mode): fix check for prompt redisplay on mode change (#11547)
parent
b9c4e2e8
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
11 deletions
+16
-11
vi-mode.plugin.zsh
plugins/vi-mode/vi-mode.plugin.zsh
+16
-11
No files found.
plugins/vi-mode/vi-mode.plugin.zsh
View file @
cc991321
...
...
@@ -43,12 +43,25 @@ function _vi-mode-set-cursor-shape-for-keymap() {
printf
$'
\e
[%d q'
"
${
_shape
}
"
}
function
_vi-mode-should-reset-prompt
()
{
# If $VI_MODE_RESET_PROMPT_ON_MODE_CHANGE is unset (default), dynamically
# check whether we're using the prompt to display vi-mode info
if
[[
-z
"
${
VI_MODE_RESET_PROMPT_ON_MODE_CHANGE
:-}
"
]]
;
then
[[
"
${
PS1
}
${
RPS1
}
"
=
*
'$(vi_mode_prompt_info)'
*
]]
return
$?
fi
# If $VI_MODE_RESET_PROMPT_ON_MODE_CHANGE was manually set, let's check
# if it was specifically set to true or it was disabled with any other value
[[
"
${
VI_MODE_RESET_PROMPT_ON_MODE_CHANGE
}
"
=
true
]]
}
# Updates editor information when the keymap changes.
function
zle-keymap-select
()
{
# update keymap variable for the prompt
typeset
-g
VI_KEYMAP
=
$KEYMAP
if
[[
"
${
VI_MODE_RESET_PROMPT_ON_MODE_CHANGE
:-}
"
=
true
]]
;
then
if
_vi-mode-should-reset-prompt
;
then
zle reset-prompt
zle
-R
fi
...
...
@@ -59,10 +72,9 @@ zle -N zle-keymap-select
# These "echoti" statements were originally set in lib/key-bindings.zsh
# Not sure the best way to extend without overriding.
function
zle-line-init
()
{
local
prev_vi_keymap
prev_vi_keymap
=
"
${
VI_KEYMAP
:-}
"
local
prev_vi_keymap
=
"
${
VI_KEYMAP
:-}
"
typeset
-g
VI_KEYMAP
=
main
[[
"
$prev_vi_keymap
"
!=
'main'
]]
&&
[[
"
${
VI_MODE_RESET_PROMPT_ON_MODE_CHANGE
:-}
"
=
true
]]
&&
zle reset-prompt
[[
"
$prev_vi_keymap
"
!=
'main'
]]
&&
_vi-mode-should-reset-prompt
&&
zle reset-prompt
((
!
${
+terminfo[smkx]
}
))
||
echoti smkx
_vi-mode-set-cursor-shape-for-keymap
"
${
VI_KEYMAP
}
"
}
...
...
@@ -138,13 +150,6 @@ if [[ -z "$MODE_INDICATOR" ]]; then
fi
function
vi_mode_prompt_info
()
{
# If we're using the prompt to display mode info, and we haven't explicitly
# disabled "reset prompt on mode change", then set it here.
#
# We do that here instead of the `if` statement below because the user may
# set RPS1/RPROMPT to something else in their custom config.
:
"
${
VI_MODE_RESET_PROMPT_ON_MODE_CHANGE
:
=true
}
"
echo
"
${${
VI_KEYMAP
/vicmd/
$MODE_INDICATOR
}
/(main|viins)/
$INSERT_MODE_INDICATOR
}
"
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment