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 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.
This configuration will render a right-aligned git segment when you type `git` or `g` followed by a space.
A tip should not include any leading or trailing space but an interpolated one can be used, e.g., `g s`.
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

View file

@ -88,7 +88,6 @@ New-Module -Name "oh-my-posh-core" -ScriptBlock {
$command = $null
$cursor = $null
[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"))
Write-Host $standardOut -NoNewline
$host.UI.RawUI.CursorPosition = $position

View file

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