diff --git a/layout.go b/layout.go index 65c7b47..9d0dcd9 100644 --- a/layout.go +++ b/layout.go @@ -14,7 +14,10 @@ import ( "github.com/peco/peco/line" ) -var extraOffset int = 0 +// extraOffset is a platform-specific constant that adds extra vertical +// space to layout anchors. On Windows, terminals need an additional line +// reserved at the bottom. Set per-platform via layout_windows.go and +// layout_notwindows.go. // ansiLiner is an optional interface for lines that carry ANSI color attributes. type ansiLiner interface { diff --git a/layout_any.go b/layout_any.go new file mode 100644 index 0000000..521d648 --- /dev/null +++ b/layout_any.go @@ -0,0 +1,5 @@ +//go:build !windows + +package peco + +const extraOffset = 0 diff --git a/layout_windows.go b/layout_windows.go index 364a61d..36fcf1e 100644 --- a/layout_windows.go +++ b/layout_windows.go @@ -1,7 +1,5 @@ package peco -func init() { - // This is the value we pass to anchor offset when we're running - // on windows platform - extraOffset = 1 -} +// extraOffset reserves one additional line at the bottom on Windows +// to account for platform-specific terminal rendering behavior. +const extraOffset = 1