Change default --ellipsis to '··'

This commit is contained in:
Junegunn Choi 2024-08-27 19:39:09 +09:00
parent 2775b771f2
commit e0924d27b8
No known key found for this signature in database
GPG Key ID: 254BC280FEF9C627
5 changed files with 21 additions and 8 deletions

View File

@ -23,6 +23,7 @@ CHANGELOG
fzf --preview "printf '<< \e]8;;http://github.com/junegunn/fzf\e\\Link to \e[32mfz\e[0mf\e]8;;\e\\ >>'" fzf --preview "printf '<< \e]8;;http://github.com/junegunn/fzf\e\\Link to \e[32mfz\e[0mf\e]8;;\e\\ >>'"
``` ```
- The default `--ellipsis` is now `··` instead of `..`.
- [vim] A spec can have `exit` callback that is called with the exit status of fzf - [vim] A spec can have `exit` callback that is called with the exit status of fzf
- This can be used to clean up temporary resources or restore the original state when fzf is closed without a selection - This can be used to clean up temporary resources or restore the original state when fzf is closed without a selection
- Fixed `--tmux bottom` when the status line is not at the bottom - Fixed `--tmux bottom` when the status line is not at the bottom

View File

@ -526,7 +526,7 @@ lines that follow.
Print header before the prompt line Print header before the prompt line
.TP .TP
.BI "\-\-ellipsis=" "STR" .BI "\-\-ellipsis=" "STR"
Ellipsis to show when line is truncated (default: '..') Ellipsis to show when line is truncated (default: '··')
.SS Display .SS Display
.TP .TP
.B "\-\-ansi" .B "\-\-ansi"

View File

@ -103,7 +103,7 @@ Usage: fzf [options]
--header=STR String to print as header --header=STR String to print as header
--header-lines=N The first N lines of the input are treated as header --header-lines=N The first N lines of the input are treated as header
--header-first Print header before the prompt line --header-first Print header before the prompt line
--ellipsis=STR Ellipsis to show when line is truncated (default: '..') --ellipsis=STR Ellipsis to show when line is truncated (default: '··')
Display Display
--ansi Enable processing of ANSI color codes --ansi Enable processing of ANSI color codes
@ -472,7 +472,7 @@ type Options struct {
Header []string Header []string
HeaderLines int HeaderLines int
HeaderFirst bool HeaderFirst bool
Ellipsis string Ellipsis *string
Scrollbar *string Scrollbar *string
Margin [4]sizeSpec Margin [4]sizeSpec
Padding [4]sizeSpec Padding [4]sizeSpec
@ -578,7 +578,7 @@ func defaultOptions() *Options {
Header: make([]string, 0), Header: make([]string, 0),
HeaderLines: 0, HeaderLines: 0,
HeaderFirst: false, HeaderFirst: false,
Ellipsis: "..", Ellipsis: nil,
Scrollbar: nil, Scrollbar: nil,
Margin: defaultMargin(), Margin: defaultMargin(),
Padding: defaultMargin(), Padding: defaultMargin(),
@ -2339,9 +2339,12 @@ func parseOptions(index *int, opts *Options, allArgs []string) error {
case "--no-header-first": case "--no-header-first":
opts.HeaderFirst = false opts.HeaderFirst = false
case "--ellipsis": case "--ellipsis":
if opts.Ellipsis, err = nextString(allArgs, &i, "ellipsis string required"); err != nil { str, err := nextString(allArgs, &i, "ellipsis string required")
if err != nil {
return err return err
} }
str = firstLine(str)
opts.Ellipsis = &str
case "--preview": case "--preview":
if opts.Preview.command, err = nextString(allArgs, &i, "preview command required"); err != nil { if opts.Preview.command, err = nextString(allArgs, &i, "preview command required"); err != nil {
return err return err
@ -2623,7 +2626,8 @@ func parseOptions(index *int, opts *Options, allArgs []string) error {
return err return err
} }
} else if match, value := optString(arg, "--ellipsis="); match { } else if match, value := optString(arg, "--ellipsis="); match {
opts.Ellipsis = value str := firstLine(value)
opts.Ellipsis = &str
} else if match, value := optString(arg, "--preview="); match { } else if match, value := optString(arg, "--preview="); match {
opts.Preview.command = value opts.Preview.command = value
} else if match, value := optString(arg, "--preview-window="); match { } else if match, value := optString(arg, "--preview-window="); match {

View File

@ -827,7 +827,6 @@ func NewTerminal(opts *Options, eventBox *util.EventBox, executor *util.Executor
headerLines: opts.HeaderLines, headerLines: opts.HeaderLines,
header: []string{}, header: []string{},
header0: opts.Header, header0: opts.Header,
ellipsis: opts.Ellipsis,
ansi: opts.Ansi, ansi: opts.Ansi,
tabstop: opts.Tabstop, tabstop: opts.Tabstop,
hasStartActions: false, hasStartActions: false,
@ -884,6 +883,15 @@ func NewTerminal(opts *Options, eventBox *util.EventBox, executor *util.Executor
} }
t.separator, t.separatorLen = t.ansiLabelPrinter(bar, &tui.ColSeparator, true) t.separator, t.separatorLen = t.ansiLabelPrinter(bar, &tui.ColSeparator, true)
} }
if opts.Ellipsis != nil {
t.ellipsis = *opts.Ellipsis
} else if t.unicode {
t.ellipsis = "··"
} else {
t.ellipsis = ".."
}
if t.unicode { if t.unicode {
t.wrapSign = "↳ " t.wrapSign = "↳ "
t.borderWidth = uniseg.StringWidth("│") t.borderWidth = uniseg.StringWidth("│")

View File

@ -1443,7 +1443,7 @@ class TestGoFZF < TestBase
[0, 3, 6].each do |off| [0, 3, 6].each do |off|
tmux.prepare tmux.prepare
tmux.send_keys "#{FZF} --hscroll-off=#{off} -q 0 < #{tempname}", :Enter tmux.send_keys "#{FZF} --hscroll-off=#{off} -q 0 < #{tempname}", :Enter
tmux.until { |lines| assert lines[-3]&.end_with?((0..off).to_a.join + '..') } tmux.until { |lines| assert lines[-3]&.end_with?((0..off).to_a.join + '··') }
tmux.send_keys '9' tmux.send_keys '9'
tmux.until { |lines| assert lines[-3]&.end_with?('789') } tmux.until { |lines| assert lines[-3]&.end_with?('789') }
tmux.send_keys :Enter tmux.send_keys :Enter