mirror of
https://github.com/fish-shell/fish-shell
synced 2025-01-13 21:44:16 +00:00
parent
a64c372a28
commit
15e095233b
1 changed files with 25 additions and 3 deletions
|
@ -88,9 +88,31 @@ function funced --description 'Edit function definition'
|
||||||
else
|
else
|
||||||
echo $init > $tmpname
|
echo $init > $tmpname
|
||||||
end
|
end
|
||||||
if eval $editor $tmpname
|
# Repeatedly edit until it either parses successfully, or the user cancels
|
||||||
. $tmpname
|
# If the editor command itself fails, we assume the user cancelled or the file
|
||||||
end
|
# could not be edited, and we do not try again
|
||||||
|
while true
|
||||||
|
if not eval $editor $tmpname
|
||||||
|
_ "Editing failed or was cancelled"
|
||||||
|
echo
|
||||||
|
else
|
||||||
|
if not source $tmpname
|
||||||
|
# Failed to source the function file. Prompt to try again.
|
||||||
|
echo # add a line between the parse error and the prompt
|
||||||
|
set -l repeat
|
||||||
|
set -l prompt (_ 'Edit the file again\? [Y/n]')
|
||||||
|
while test -z "$repeat"
|
||||||
|
read -p "echo $prompt\ " repeat
|
||||||
|
end
|
||||||
|
if not contains $repeat n N no NO No nO
|
||||||
|
continue
|
||||||
|
end
|
||||||
|
_ "Cancelled function editing"
|
||||||
|
echo
|
||||||
|
end
|
||||||
|
end
|
||||||
|
break
|
||||||
|
end
|
||||||
set -l stat $status
|
set -l stat $status
|
||||||
rm -f $tmpname >/dev/null
|
rm -f $tmpname >/dev/null
|
||||||
return $stat
|
return $stat
|
||||||
|
|
Loading…
Reference in a new issue