Skip to content
Myr

Add --keep-right option to keep the right end of the line visible

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Close #1652

authored by Junegunn Choi · committed by Junegunn Choi · parent b8fc828 · Browse files · 5 files+31 added−6 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

5 files+31 added−6 removed

  • tests:+5 added−0 removed
  • other:+26 added−6 removed

5 files+31 added−6 removed

modified:man/man1/fzf.1+4 added
128 unmodified lines
129.TP130.B "--cycle"131Enable cyclic scroll132.TP133.B "--keep-right"134Keep the right end of the line visible when it's too long. Effective only when135the query string is empty.136.TP137.B "--no-hscroll"138Disable horizontal scroll139.TP140.BI "--hscroll-off=" "COL"
651 unmodified lines
modified:src/options.go+7 added
42 unmodified lines
43 -m, --multi[=MAX] Enable multi-select with tab/shift-tab44 --no-mouse Disable mouse45 --bind=KEYBINDS Custom key bindings. Refer to the man page.46 --cycle Enable cyclic scroll47 --keep-right Keep the right end of the line visible on overflow48 --no-hscroll Disable horizontal scroll49 --hscroll-off=COL Number of screen columns to keep to the right of the50 highlighted substring (default: 10)51 --filepath-word Make word-wise movements respect path separators
135 unmodified lines
187 Height sizeSpec188 MinHeight int189 Layout layoutType190 Cycle bool191 KeepRight bool192 Hscroll bool193 HscrollOff int194 FileWord bool195 InfoStyle infoStyle
47 unmodified lines
243 Bold: true,244 MinHeight: 10,245 Layout: layoutDefault,246 Cycle: false,247 KeepRight: false,248 Hscroll: true,249 HscrollOff: 10,250 FileWord: false,251 InfoStyle: infoDefault,
924 unmodified lines
1176 case "--cycle":1177 opts.Cycle = true1178 case "--no-cycle":1179 opts.Cycle = false1180 case "--keep-right":1181 opts.KeepRight = true1182 case "--no-keep-right":1183 opts.KeepRight = false1184 case "--hscroll":1185 opts.Hscroll = true1186 case "--no-hscroll":1187 opts.Hscroll = false
286 unmodified lines
modified:src/terminal.go+13 added-6 removed
23 unmodified lines
2425var placeholder *regexp.Regexp26var activeTempFiles []string2728const ellipsis string = ".."2930func init() {31 placeholder = regexp.MustCompile(`\\?(?:{[+sf]*[0-9,-.]*}|{q}|{\+?f?nf?})`)32 activeTempFiles = []string{}33}
40 unmodified lines
74 markerEmpty string75 queryLen [2]int76 layout layoutType77 fullscreen bool78 keepRight bool79 hscroll bool80 hscrollOff int81 wordRubout string82 wordNext string
316 unmodified lines
399 spinner: spinner,400 queryLen: [2]int{0, 0},401 layout: opts.Layout,402 fullscreen: fullscreen,403 keepRight: opts.KeepRight,404 hscroll: opts.Hscroll,405 hscrollOff: opts.HscrollOff,406 wordRubout: wordRubout,407 wordNext: wordNext,
595 unmodified lines
1003 maxe = util.Constrain(maxe+util.Min(maxWidth/2-2, t.hscrollOff), 0, len(text))1004 displayWidth := t.displayWidthWithLimit(text, 0, maxWidth)1005 if displayWidth > maxWidth {1006 if t.hscroll {1003 // Stri..1004 if !t.overflow(text[:maxe], maxWidth-2) {1007 if t.keepRight && pos == nil {1008 text, _ = t.trimLeft(text, maxWidth-2)1009 text = append([]rune(ellipsis), text...)1010 } else if !t.overflow(text[:maxe], maxWidth-2) {1011 // Stri..1012 text, _ = t.trimRight(text, maxWidth-2)1006 text = append(text, []rune("..")...)1013 text = append(text, []rune(ellipsis)...)1014 } else {1015 // Stri..1016 if t.overflow(text[maxe:], 2) {1010 text = append(text[:maxe], []rune("..")...)1017 text = append(text[:maxe], []rune(ellipsis)...)1018 }1019 // ..ri..1020 var diff int321021 text, diff = t.trimLeft(text, maxWidth-2)
6 unmodified lines
1028 b = util.Max32(b, 2)1029 offsets[idx].offset[0] = b1030 offsets[idx].offset[1] = util.Max32(b, e)1031 }1025 text = append([]rune(".."), text...)1032 text = append([]rune(ellipsis), text...)1033 }1034 } else {1035 text, _ = t.trimRight(text, maxWidth-2)1029 text = append(text, []rune("..")...)1036 text = append(text, []rune(ellipsis)...)10371038 for idx, offset := range offsets {1039 offsets[idx].offset[0] = util.Min32(offset.offset[0], int32(maxWidth-2))1040 offsets[idx].offset[1] = util.Min32(offset.offset[1], int32(maxWidth))
1187 unmodified lines
modified:test/test_go.rb+5 added
1726 unmodified lines
1727 tmux.until { |lines| lines.any_include?('bar foo') }1728 tmux.send_keys :Enter1729 end1730 end17311732 def test_keep_right1733 tmux.send_keys("seq 10000 | #{FZF} --read0 --keep-right", :Enter)1734 tmux.until { |lines| lines.any_include?('9999 10000') }1735 end1736end17371738module TestShell1739 def setup
474 unmodified lines
modified:CHANGELOG.md+2 added
9 unmodified lines
10 The previous style is available via `--border=horizontal`11- Added `--pointer` and `--marker` options12- `--height` option is now available on Windows binary (@kelleyma49)13- More keys and actions for `--bind`14- Added `--keep-right` option that keeps the right end of the line visible15 when it's too long16- Bug fixes and improvements17- Vim plugin: Floating windows support18- bash: Various improvements in key bindings (CTRL-T, CTRL-R, ALT-C)19- Fuzzy completion API changed
813 unmodified lines