Closed zenazn closed 10 years ago
Oh, I forgot to mention: one reason I'm not comfortable PRing the patch I mentioned above is that I'm not sure how it works with other shells. The behavior here, for instance, seems to be caused by vim's interactions with sh
, ksh
, and bash
: see help shellredir
for more.
Hey @zenazn thanks for the report. Let me check this behavior at the weekend once I have time to dig in. I've also encountered something similar on my own code but it's happened only once. But first of all I need a working test.go file that produces this error for me :)
I have also seen this issue. It's quite frustrating as you can't use your editor to fix the editor's bug! I ended up using Atom to fix it out-of-band.
Let me see if I can repro with the library I was working on. It isn't currently publicly available, but it may be soon.
I'm getting a very similar situation, on save with goimports it injects text describing a parse error in a file from another project in my go project root. Once it happens I can not make it go away unless I reboot the computer and then all is fine again (until it happens). (I've tried restarting the macvim process, no help). So I'm not sure if its an env setting that gets whacked or what.
just a followup, I deleted the other project directory and the issue stopped. I'm not sure why goimports on save would be parsing other project paths, is this a goimports bug or does vim-go send the filepaths?
@troyk could you provide with some test data that I can also reproduce it? I'm trying to reproduce it without any success. As for goimports, vim-go only passes the current filename to goimports. gofmt and goimports both works with the same code.
This seems to be fixed now. Please try to test with by pulling the latest master and let me know. I've tested it with two cases could not import
and could not parse
which seems to be fixed now.
I've recently come across a very bizarre interaction between
fmt
-on-save, vim-go, andgoimports
, where they all conspire to produce a file with a syntax error that I am unable to fix using vim (i.e., fixing the file and saving it triggers this bug, which reintroduces the syntax error).I have encountered this bug in several projects and have several reliable reproducers, however I cannot publish the source of any of them here, and the bug has eluded all of my attempts to isolate it into a test case I can distribute.
The gist of the bug is that
goimports
can under some circumstances exit successfully while printing an error message to stderr. This results in a file that looks something like this:This file is sort of a "fixed point" if you will, where attempting to correct the first line to read
package problematic
causesgoimports
to exit 0 but print the same error message (to stderr) that caused the problem in the first place.The error message in question I think is coming from https://code.google.com/p/go/source/browse/imports/fix.go?repo=tools#282
As a simple patch, changing
ftplugin/go/fmt.vim
to readsilent execute "%!" . command . " 2>/dev/null"
instead ofsilent execute "%!" . command
is sufficient to work around the problem.I'm not sure if there's a better patch here, or if the bug ought to be filed with (e.g.,)
goimports
, but it sure as hell is annoying :)