mirror of
https://github.com/Llewellynvdm/fzf.git
synced 2025-01-25 16:18:27 +00:00
Lift unicode.IsGraphic constraint for pointer, marker, and ellipsis
Use at your own risk. Close #2709 Close #2055
This commit is contained in:
parent
52594355bf
commit
7a7cfcacbe
@ -14,6 +14,9 @@ CHANGELOG
|
|||||||
fzf --preview 'cat {}' --preview-window '<50(hidden)'
|
fzf --preview 'cat {}' --preview-window '<50(hidden)'
|
||||||
```
|
```
|
||||||
- Use SGR mouse mode to support larger terminals
|
- Use SGR mouse mode to support larger terminals
|
||||||
|
- You can now use characters that does not satisfy `unicode.IsGraphic` constraint
|
||||||
|
for `--marker`, `--pointer`, and `--ellipsis`. Allows Nerd Fonts and stuff.
|
||||||
|
Use at your own risk.
|
||||||
- Bug fixes and improvements
|
- Bug fixes and improvements
|
||||||
- Shell extension
|
- Shell extension
|
||||||
- `kill` completion now requires trigger sequence (`**`) for consistency
|
- `kill` completion now requires trigger sequence (`**`) for consistency
|
||||||
|
@ -1307,7 +1307,6 @@ func parseOptions(opts *Options, allArgs []string) {
|
|||||||
validateJumpLabels := false
|
validateJumpLabels := false
|
||||||
validatePointer := false
|
validatePointer := false
|
||||||
validateMarker := false
|
validateMarker := false
|
||||||
validateEllipsis := false
|
|
||||||
for i := 0; i < len(allArgs); i++ {
|
for i := 0; i < len(allArgs); i++ {
|
||||||
arg := allArgs[i]
|
arg := allArgs[i]
|
||||||
switch arg {
|
switch arg {
|
||||||
@ -1495,7 +1494,6 @@ func parseOptions(opts *Options, allArgs []string) {
|
|||||||
opts.HeaderFirst = false
|
opts.HeaderFirst = false
|
||||||
case "--ellipsis":
|
case "--ellipsis":
|
||||||
opts.Ellipsis = nextString(allArgs, &i, "ellipsis string required")
|
opts.Ellipsis = nextString(allArgs, &i, "ellipsis string required")
|
||||||
validateEllipsis = true
|
|
||||||
case "--preview":
|
case "--preview":
|
||||||
opts.Preview.command = nextString(allArgs, &i, "preview command required")
|
opts.Preview.command = nextString(allArgs, &i, "preview command required")
|
||||||
case "--no-preview":
|
case "--no-preview":
|
||||||
@ -1595,7 +1593,6 @@ func parseOptions(opts *Options, allArgs []string) {
|
|||||||
opts.HeaderLines = atoi(value)
|
opts.HeaderLines = atoi(value)
|
||||||
} else if match, value := optString(arg, "--ellipsis="); match {
|
} else if match, value := optString(arg, "--ellipsis="); match {
|
||||||
opts.Ellipsis = value
|
opts.Ellipsis = value
|
||||||
validateEllipsis = true
|
|
||||||
} 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 {
|
||||||
@ -1658,25 +1655,12 @@ func parseOptions(opts *Options, allArgs []string) {
|
|||||||
errorExit(err.Error())
|
errorExit(err.Error())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if validateEllipsis {
|
|
||||||
for _, r := range opts.Ellipsis {
|
|
||||||
if !unicode.IsGraphic(r) {
|
|
||||||
errorExit("invalid character in ellipsis")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func validateSign(sign string, signOptName string) error {
|
func validateSign(sign string, signOptName string) error {
|
||||||
if sign == "" {
|
if sign == "" {
|
||||||
return fmt.Errorf("%v cannot be empty", signOptName)
|
return fmt.Errorf("%v cannot be empty", signOptName)
|
||||||
}
|
}
|
||||||
for _, r := range sign {
|
|
||||||
if !unicode.IsGraphic(r) {
|
|
||||||
return fmt.Errorf("invalid character in %v", signOptName)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if runewidth.StringWidth(sign) > 2 {
|
if runewidth.StringWidth(sign) > 2 {
|
||||||
return fmt.Errorf("%v display width should be up to 2", signOptName)
|
return fmt.Errorf("%v display width should be up to 2", signOptName)
|
||||||
}
|
}
|
||||||
|
@ -453,8 +453,6 @@ func TestValidateSign(t *testing.T) {
|
|||||||
{"😀", true},
|
{"😀", true},
|
||||||
{"", false},
|
{"", false},
|
||||||
{">>>", false},
|
{">>>", false},
|
||||||
{"\n", false},
|
|
||||||
{"\t", false},
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, testCase := range testCases {
|
for _, testCase := range testCases {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user