Set the default value of --min-height depending on other options
Before adoption: this commit came in with the history the project adopted, so no landing records it.
authored by Junegunn Choi · committed by Junegunn Choi · parent a6a558d · Browse files · 3 files·+50 added−14 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
3 files+50 added−14 removed
- other:+50 added−14 removed
Provenance
- Commit
51c2074- Tree
9b8a8a6- Author
Junegunn Choi <junegunn.c@gmail.com>- Committer
Junegunn Choi <junegunn.c@gmail.com>- Parent
a6a558d
3 files changed+50 added−14 removed
modified:src/options.go+48 added-2 removed
68 unmodified lines69 minus the given value.70 If prefixed with '~', fzf will determine the height71 according to the input size.72 --min-height=HEIGHT Minimum height for percent --height is given in percent73- (default: 10)73+ (default: 10 or above depending on the other options)74 --tmux[=OPTS] Start fzf in a tmux popup (requires tmux 3.3+)75 [center|top|bottom|left|right][,SIZE[%]][,SIZE[%]]76 [,border-native] (default: center,50%)77 594 unmodified lines672 Mouse: true,673 Theme: theme,674 Black: false,675 Bold: true,676- MinHeight: 10,676+ MinHeight: -1,677 Layout: layoutDefault,678 Cycle: false,679 Wrap: false,680 MultiLine: true,2356 unmodified lines3037 3038 return nil3039 }3040 3041+func noSeparatorLine(style infoStyle, separator bool) bool {3042+ switch style {3043+ case infoInline:3044+ return true3045+ case infoHidden, infoInlineRight:3046+ return !separator3047+ }3048+ return false3049+}3050+3051+func (opts *Options) noSeparatorLine() bool {3052+ sep := opts.Separator == nil && !opts.InputBorderShape.Visible() || opts.Separator != nil && len(*opts.Separator) > 03053+ return noSeparatorLine(opts.InfoStyle, sep)3054+}3055+3056 // This function can have side-effects and alter some global states.3057 // So we run it on fzf.Run and not on ParseOptions.3058 func postProcessOptions(opts *Options) error {3059 if opts.Ambidouble {157 unmodified lines3217 if !tui.IsLightRendererSupported() && opts.Height.size > 0 {3218 opts.Height = heightSpec{}3219 }3220 3221+ // Sets --min-height automatically3222+ if opts.Height.size > 0 && opts.Height.percent && opts.MinHeight < 0 {3223+ // 10 items and 1 prompt line3224+ opts.MinHeight = 10 + 1 + borderLines(opts.BorderShape) + borderLines(opts.ListBorderShape) + borderLines(opts.InputBorderShape)3225+ if len(opts.Header) > 0 {3226+ opts.MinHeight += borderLines(opts.HeaderBorderShape) + len(opts.Header)3227+ }3228+ if opts.HeaderLines > 0 {3229+ borderShape := opts.HeaderBorderShape3230+ if opts.HeaderLinesShape.Visible() {3231+ borderShape = opts.HeaderLinesShape3232+ }3233+ opts.MinHeight += borderLines(borderShape) + opts.HeaderLines3234+ }3235+ if !opts.noSeparatorLine() {3236+ opts.MinHeight++3237+ }3238+ if len(opts.Preview.command) > 0 && (opts.Preview.position == posUp || opts.Preview.position == posDown) && opts.Preview.Visible() && opts.Preview.position == posUp {3239+ borderShape := opts.Preview.border3240+ if opts.Preview.border == tui.BorderLine {3241+ borderShape = tui.BorderTop3242+ }3243+ opts.MinHeight += borderLines(borderShape) + 103244+ }3245+ for _, s := range []sizeSpec{opts.Margin[0], opts.Margin[2], opts.Padding[0], opts.Padding[2]} {3246+ if !s.percent {3247+ opts.MinHeight += int(s.size)3248+ }3249+ }3250+ }3251+3252 if err := opts.initProfiling(); err != nil {3253 return errors.New("failed to start pprof profiles: " + err.Error())3254 }3255 105 unmodified linesmodified:src/terminal.go+1 added-11 removed
797 unmodified lines798 effectiveMinHeight := minHeight799 if previewBox != nil && opts.Preview.aboveOrBelow() {800 effectiveMinHeight += 1 + borderLines(opts.Preview.Border())801 }802- if noSeparatorLine(opts.InfoStyle, opts.Separator == nil || uniseg.StringWidth(*opts.Separator) > 0) {802+ if opts.noSeparatorLine() {803 effectiveMinHeight--804 }805 effectiveMinHeight += borderLines(opts.BorderShape)806 return util.Min(termHeight, util.Max(evaluateHeight(opts, termHeight), effectiveMinHeight))456 unmodified lines1263 1264 return output, promptLen1265 }1266 1267-func noSeparatorLine(style infoStyle, separator bool) bool {1268- switch style {1269- case infoInline:1270- return true1271- case infoHidden, infoInlineRight:1272- return !separator1273- }1274- return false1275-}1276-1267 func (t *Terminal) noSeparatorLine() bool {1268 return noSeparatorLine(t.infoStyle, t.separatorLen > 0)1269 }1270 4829 unmodified linesmodified:ADVANCED.md+1 added-1 removed
91 unmodified lines92 ```93 94 95 96-*(See `Layout` section of the man page to see the full list of options)*96+*(See man page to see the full list of options)*97 98 But you definitely don't want to repeat `--height=40% --layout=reverse99 --info=inline --border --margin=1 --padding=1` every time you use fzf. You100 could write a wrapper script or shell alias, but there is an easier option.615 unmodified lines