mirror of
https://github.com/fish-shell/fish-shell
synced 2024-12-29 06:13:20 +00:00
completions/git: support ... range notation
https://git-scm.com/docs/gitrevisions#_revision_range_summary
This commit is contained in:
parent
2a95b283ee
commit
618705285d
1 changed files with 11 additions and 5 deletions
|
@ -511,12 +511,18 @@ function __fish_git_needs_rev_files
|
|||
end
|
||||
|
||||
function __fish_git_ranges
|
||||
set -l both (commandline -ot | string split "..")
|
||||
set -l both (commandline -ot | string replace -r '\.{2,3}' \n\$0\n)
|
||||
set -l from $both[1]
|
||||
set -l dots $both[2]
|
||||
# If we didn't need to split (or there's nothing _to_ split), complete only the first part
|
||||
# Note that status here is from `string split` because `set` doesn't alter it
|
||||
# Note that status here is from `string replace` because `set` doesn't alter it
|
||||
if test -z "$from" -o $status -gt 0
|
||||
__fish_git_refs
|
||||
if commandline -ct | string match -q '*..*'
|
||||
# The cursor is right of a .. range operator, make sure to include them first.
|
||||
__fish_git_refs | string replace -r '' "$dots"
|
||||
else
|
||||
__fish_git_refs | string replace \t "$dots"\t
|
||||
end
|
||||
return 0
|
||||
end
|
||||
|
||||
|
@ -528,11 +534,11 @@ function __fish_git_ranges
|
|||
set from_refs (__fish_git_refs | string match -e "$from" | string replace -r \t'.*$' '')
|
||||
end
|
||||
|
||||
set -l to $both[2]
|
||||
set -l to $both[3]
|
||||
# Remove description from the from-ref, not the to-ref.
|
||||
for from_ref in $from_refs
|
||||
for to_ref in (__fish_git_refs | string match "*$to*") # if $to is empty, this correctly matches everything
|
||||
printf "%s..%s\n" $from_ref $to_ref
|
||||
printf "%s%s%s\n" $from_ref $dots $to_ref
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue