refactor: align tooltip behaviors

This commit is contained in:
L. Yeung 2022-04-27 22:41:32 +08:00 committed by Jan De Dobbeleer
parent 9606d5a105
commit fccdfe5306
3 changed files with 6 additions and 6 deletions

View file

@ -49,9 +49,9 @@ You need to extend or create a custom theme with your tooltips. For example:
} }
``` ```
This configuration will render a right-aligned git segment when you type `git` or `g` followed by a space. Keep in mind that This configuration will render a right-aligned git segment when you type `git` or `g` followed by a space.
this is a blocking call, meaning that if the segment renders slow, you can't type until it's visible. Optimizations in this space A tip should not include any leading or trailing space but an interpolated one can be used, e.g., `g s`.
are being explored. Keep in mind that this is a blocking call, meaning that if the segment renders slow, you can't type until it's visible. Optimizations in this space are being explored.
## Enable the feature ## Enable the feature

View file

@ -88,7 +88,6 @@ New-Module -Name "oh-my-posh-core" -ScriptBlock {
$command = $null $command = $null
$cursor = $null $cursor = $null
[Microsoft.PowerShell.PSConsoleReadLine]::GetBufferState([ref]$command, [ref]$cursor) [Microsoft.PowerShell.PSConsoleReadLine]::GetBufferState([ref]$command, [ref]$cursor)
$command = ($command -split " ")[0]
$standardOut = @(Start-Utf8Process $script:OMPExecutable @("print", "tooltip", "--pwd=$cleanPWD", "--pswd=$cleanPSWD", "--config=$env:POSH_THEME", "--command=$command", "--shell-version=$script:PSVersion")) $standardOut = @(Start-Utf8Process $script:OMPExecutable @("print", "tooltip", "--pwd=$cleanPWD", "--pswd=$cleanPSWD", "--config=$env:POSH_THEME", "--command=$command", "--shell-version=$script:PSVersion"))
Write-Host $standardOut -NoNewline Write-Host $standardOut -NoNewline
$host.UI.RawUI.CursorPosition = $position $host.UI.RawUI.CursorPosition = $position

View file

@ -42,7 +42,7 @@ if [ "$TERM" != "linux" ]; then
_install-omp-hooks _install-omp-hooks
fi fi
function self-insert() { function _render_tooltip() {
# ignore an empty buffer # ignore an empty buffer
if [[ -z "$BUFFER" ]]; then if [[ -z "$BUFFER" ]]; then
zle .self-insert zle .self-insert
@ -58,7 +58,8 @@ function self-insert() {
} }
function enable_poshtooltips() { function enable_poshtooltips() {
zle -N self-insert zle -N _render_tooltip
bindkey " " _render_tooltip
} }
_posh-zle-line-init() { _posh-zle-line-init() {