mirror of
https://github.com/wfxr/forgit.git
synced 2026-09-10 07:16:23 -04:00
fix: preserve LESS options in enter pager
Pass the required color and stay-open flags directly to less so forgit no longer replaces users' LESS environment options. Add regression coverage and document the default behavior.
This commit is contained in:
parent
15db001662
commit
e0973351b8
|
|
@ -317,9 +317,14 @@ variables:
|
|||
| `FORGIT_BLAME_PAGER` | `git config pager.blame` _or_ `$FORGIT_PAGER` |
|
||||
| `FORGIT_IGNORE_PAGER` | `bat -l gitignore --color always` _or_ `cat` |
|
||||
| `FORGIT_ATTRIBUTES_PAGER` | `bat -l gitattributes --color always` _or_ `cat` |
|
||||
| `FORGIT_PREVIEW_PAGER` | Normal pager resolution<sup>*</sup> |
|
||||
| `FORGIT_ENTER_PAGER` | `less -R -+F -+E`<sup>1</sup> |
|
||||
| `FORGIT_PREVIEW_PAGER` | Normal pager resolution<sup>2</sup> |
|
||||
|
||||
<sup>*</sup> If your pager is a TUI program (e.g., `diffnav`, `tig`), fzf preview panes will be blank because they run
|
||||
<sup>1</sup> `FORGIT_ENTER_PAGER` controls the full-screen pager opened by the Enter key. Its default inherits options
|
||||
from `LESS`, enables safe ANSI color handling with `-R`, and disables `-F` and `-E` so the pager remains open for short
|
||||
output. Setting `FORGIT_ENTER_PAGER` replaces the default command.
|
||||
|
||||
<sup>2</sup> If your pager is a TUI program (e.g., `diffnav`, `tig`), fzf preview panes will be blank because they run
|
||||
without a TTY. Set `FORGIT_PREVIEW_PAGER` to a non-interactive pager (e.g., `delta`) to fix this. When set, it
|
||||
overrides all other `FORGIT_*_PAGER` settings in fzf preview context.
|
||||
|
||||
|
|
|
|||
|
|
@ -171,7 +171,7 @@ _forgit_get_pager() {
|
|||
ignore) echo -n "${FORGIT_IGNORE_PAGER:-$(hash bat &>/dev/null && echo 'bat -l gitignore --color=always' || echo 'cat')}" ;;
|
||||
attributes) echo -n "${FORGIT_ATTRIBUTES_PAGER:-$(hash bat &>/dev/null && echo 'bat -l gitattributes --color=always' || echo 'cat')}" ;;
|
||||
blame) echo -n "${FORGIT_BLAME_PAGER:-$(git config pager.blame || _forgit_get_pager)}" ;;
|
||||
enter) echo -n "${FORGIT_ENTER_PAGER:-"LESS='-r' less"}" ;;
|
||||
enter) echo -n "${FORGIT_ENTER_PAGER:-"less -R -+F -+E"}" ;;
|
||||
*) echo "pager not found: $1" >&2 ;;
|
||||
esac
|
||||
}
|
||||
|
|
|
|||
19
tests/pager.test.sh
Normal file
19
tests/pager.test.sh
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
function set_up_before_script() {
|
||||
source bin/git-forgit
|
||||
}
|
||||
|
||||
function less() {
|
||||
printf 'LESS=%s\n' "$LESS"
|
||||
printf 'ARGS=%s\n' "$*"
|
||||
}
|
||||
|
||||
function test_enter_pager_preserves_less_and_disables_automatic_exit() {
|
||||
local actual
|
||||
|
||||
actual=$(LESS="-F -E -X -S -N" _forgit_pager enter)
|
||||
|
||||
assert_contains "LESS=-F -E -X -S -N" "$actual"
|
||||
assert_contains "ARGS=-R -+F -+E" "$actual"
|
||||
}
|
||||
Loading…
Reference in a new issue