mirror of
https://github.com/Llewellynvdm/fzf.git
synced 2024-12-23 03:19:01 +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)'
|
||||
```
|
||||
- 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
|
||||
- Shell extension
|
||||
- `kill` completion now requires trigger sequence (`**`) for consistency
|
||||
|
@ -1307,7 +1307,6 @@ func parseOptions(opts *Options, allArgs []string) {
|
||||
validateJumpLabels := false
|
||||
validatePointer := false
|
||||
validateMarker := false
|
||||
validateEllipsis := false
|
||||
for i := 0; i < len(allArgs); i++ {
|
||||
arg := allArgs[i]
|
||||
switch arg {
|
||||
@ -1495,7 +1494,6 @@ func parseOptions(opts *Options, allArgs []string) {
|
||||
opts.HeaderFirst = false
|
||||
case "--ellipsis":
|
||||
opts.Ellipsis = nextString(allArgs, &i, "ellipsis string required")
|
||||
validateEllipsis = true
|
||||
case "--preview":
|
||||
opts.Preview.command = nextString(allArgs, &i, "preview command required")
|
||||
case "--no-preview":
|
||||
@ -1595,7 +1593,6 @@ func parseOptions(opts *Options, allArgs []string) {
|
||||
opts.HeaderLines = atoi(value)
|
||||
} else if match, value := optString(arg, "--ellipsis="); match {
|
||||
opts.Ellipsis = value
|
||||
validateEllipsis = true
|
||||
} else if match, value := optString(arg, "--preview="); match {
|
||||
opts.Preview.command = value
|
||||
} else if match, value := optString(arg, "--preview-window="); match {
|
||||
@ -1658,25 +1655,12 @@ func parseOptions(opts *Options, allArgs []string) {
|
||||
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 {
|
||||
if sign == "" {
|
||||
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 {
|
||||
return fmt.Errorf("%v display width should be up to 2", signOptName)
|
||||
}
|
||||
|
@ -453,8 +453,6 @@ func TestValidateSign(t *testing.T) {
|
||||
{"😀", true},
|
||||
{"", false},
|
||||
{">>>", false},
|
||||
{"\n", false},
|
||||
{"\t", false},
|
||||
}
|
||||
|
||||
for _, testCase := range testCases {
|
||||
|
Loading…
Reference in New Issue
Block a user