Skip to content

Commit 5da3dd4

Browse files
terlarlaughedelic
authored andcommitted
Fix completion with dashes (#4)
* Fix completion with dashes If I write something like curl --he<tab> it currently crashes on this string match line. This should solve this by telling the string command that it won't be any switches after this `--`-mark. * Handle dashes in string and commandline As the input might be using dashes we need to use double dashes to tell the command that there won't be any more options.
1 parent 96a34c7 commit 5da3dd4

File tree

8 files changed

+10
-10
lines changed

8 files changed

+10
-10
lines changed

functions/_pisces_append.fish

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
function _pisces_append -a text -d "Inserts a pair of strings (left-right) and puts the cursor between them"
22

3-
commandline --insert $text
4-
and _pisces_jump -(string length $text)
3+
commandline --insert -- $text
4+
and _pisces_jump -(string length -- $text)
55
end

functions/_pisces_backspace.fish

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
function _pisces_backspace -d "Overrides backspace to handle empty pairs removal"
22

33
for pair in $pisces_pairs
4-
_pisces_remove (string split ',' $pair)
4+
_pisces_remove (string split -- ',' $pair)
55
and return 0
66
end
77

functions/_pisces_bind_pair.fish

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ function _pisces_bind_pair -a left right -d "Creates bindings for the given pair
1111
bind $r "_pisces_skip $right; or _pisces_append $right"
1212
else # if $some_special_setting
1313

14-
bind $l "commandline -i $left; and _pisces_append $right"
14+
bind $l "commandline -i -- $left; and _pisces_append $right"
1515
bind $r "_pisces_skip $right"
1616
end
1717
end

functions/_pisces_complete.fish

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ function _pisces_complete -d "Invokes complete with modification for vars before
55
else
66
set token (commandline -t)
77
# checking that the current token ends on a $var + '"'
8-
if [ (string match -r '\$.*"$' "$token") ]
8+
if [ (string match -r '\$.*"$' -- "$token") ]
99
commandline -f delete-char # which is '"'
1010
end
1111
commandline -f complete

functions/_pisces_lookup.fish

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,6 @@ function _pisces_lookup -a pos len -d "Returns the text at the given position re
99
set input (commandline -b)
1010

1111
# NOTE: it's important to quote $input, because it may have newlines
12-
string sub --start (math "$cur + $pos + 1") --length $len "$input" ^/dev/null
12+
string sub --start (math "$cur + $pos + 1") --length $len -- "$input" ^/dev/null
1313
or echo '' # if it's out of bounds (probably better to return cut part)
1414
end

functions/_pisces_skip.fish

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
function _pisces_skip -a text -d "Skips given text if it's already under the cursor"
22

3-
set length (string length $text)
3+
set length (string length -- $text)
44

55
if [ (_pisces_lookup 0 $length) = $text ]
66
_pisces_jump $length
77
return 0
88
else
9-
commandline -i $text
9+
commandline -i -- $text
1010
return 1
1111
end
1212
end

key_bindings.fish

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ function key_bindings
44
or set -U pisces_pairs '(,)' '[,]' '{,}' '","' "','"
55

66
for pair in $pisces_pairs
7-
_pisces_bind_pair (string split ',' $pair)
7+
_pisces_bind_pair (string split -- ',' $pair)
88
end
99

1010
# normal backspace, also known as \010 or ^H:

uninstall.fish

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
for pair in $pisces_pairs
2-
for c in (string split ',' $pair)
2+
for c in (string split -- ',' $pair)
33
bind -e $c
44
end
55
end

0 commit comments

Comments
 (0)