'How to use VS Code as $VISUAL editor in Fish Shell, spec. `funced`

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?



Solution 1:[1]

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.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 ridiculous_fish