-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Undefined variable when redirecting command output into a string variable #33
Comments
Did some debugging in nvim with vim-markbar commit b6b43ca by:
It looks like (neo)vim maintains static variables like The
Then, before (neo)vim parses and executes a
tl;dr it looks like autocommands can interrupt/"interleave" with earlier autocommands as those earlier autocommands are still executing a Commenting out |
Work around Issue #33, in which a call like `redir => l:buffer_str` will throw an error message like `E121: Undefined variable: l:to_return` because (neo)vim didn't process another function call's `redir END`. If we're always redirecting into a variable named `l:redir_output`, then the variable lookup won't fail and spit out an error message. Also remove a superfluous VimEnter autocommand, because "interleaving" autocommands seem to be the source of the wonky redir behavior.
Work around Issue #33, in which a call like `redir => l:buffer_str` will throw an error message like `E121: Undefined variable: l:to_return` because (neo)vim didn't process another function call's `redir END`. If we're always redirecting into a variable named `l:redir_output`, then the variable lookup won't fail and spit out an error message. Also remove a superfluous VimEnter autocommand, because "interleaving" autocommands seem to be the source of the wonky redir behavior.
Always using the same name for the variable storing The underlying issue in (neo)vim still exists, but it doesn't seem to affect markbar's functionality (the markbar still works), so the error message is our main concern for now. The error message shouldn't crop up again unless some other plugin's autocommands interleave with vim-markbar's. (If you're a user and encounter this error message, please post about that here!) |
The erroneous E121 from #33 only fires once after a `redir =>`, so we can try-catch it, and then just try the same `redir =>` again.
The erroneous E121 from #33 only fires once after a `redir =>`, so we can try-catch it, and then just try the same `redir =>` again.
The erroneous E121 from #33 only fires once after a `redir =>`, so we can try-catch it, and then just try the same `redir =>` again.
Repeated my debugging process from earlier, but with vim
From inside
From the stackframe for
vim throws:
It looks like EDIT: In #38 (comment), the |
Running vim-markbar's test suite keeps throwing error messages like:
That don't seem to appear during normal use on my machine. This might be related to an issue mentioned by @mwgkgk in #3 (comment)
Relevant lines of code (that also don't reference a variable named
l:to_return
):Lower down in the same file:
When I change the above into:
I see error messages like:
And actual test failures like:
This occurs in both vim and neovim.
This may be an upstream issue in which the
redir =>
command isn't properly remembering which variables were declared in which stack frames.The text was updated successfully, but these errors were encountered: