1

I'd like to edit existing fish functions in VS Code, but can't seem to get funced to behave as expected.

Here's what I've tried:

$ set VISUAL code     # also tried /usr/local/bin/code
$ funced print_bool
Editor exited but the function was not modified
$ funced print_bool -e code   # or /usr/local/bin/code
Editor exited but the function was not modified

In each case, VS Code opens an empty file titled "print_bool.fish"…

enter image description here

…however, print_bool isn't an empty function:

$ funced print_bool -i
$ print_bool> function print_bool --argument arg
    if eval $arg
        echo true
    else
        echo false
    end
end

What am I missing here?

Navelgazer
  • 185
  • 1
  • 8
  • 1
    Does this answer your question? [How can I fix Edit cancelled, no changes made in shell](https://stackoverflow.com/questions/56811177/how-can-i-fix-edit-cancelled-no-changes-made-in-shell) – faho Apr 12 '22 at 09:40

1 Answers1

3

To use code as a synchronous editor, pass --wait:

set -x VISUAL 'code --wait'

otherwise the command will return immediately before the file is saved, so fish will conclude the file has not been changed.

ridiculous_fish
  • 17,273
  • 1
  • 54
  • 61