Skip to content
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

job: close quickfix window if a job has succeeded #1123

Merged
merged 1 commit into from
Nov 24, 2016
Merged

job: close quickfix window if a job has succeeded #1123

merged 1 commit into from
Nov 24, 2016

Conversation

pborzenkov
Copy link
Contributor

Otherwise all previous build errors are shown even after successful
build.

Signed-off-by: Pavel Borzenkov [email protected]

@@ -57,16 +57,17 @@ function go#job#Spawn(args)
endif
endif

let l:listtype = "quickfix"
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should use here: let l:listtype = go#list#Type("quickfix"). the Type() function returns the user preference (can be set via go_list_type) , if there is none, then the argument itself is returned.

@fatih
Copy link
Owner

fatih commented Nov 24, 2016

Btw, the current code is all set to quickfix, not sure how this fixes it. What exactly is the problem? Is this fixing #1109, if yes what's the real problem here?

@pborzenkov
Copy link
Contributor Author

Yes, I am experiencing the very same problem as described in #1109. And it does indeed fix it for me.

Initially, I though that go#list#Window(0) would close 'localtionlist', but now I see that it should close 'quickfix' by default. So I'm not sure how this patch fixes it, anymore :) I'm going to dig a bit deeper here.

@pborzenkov
Copy link
Contributor Author

Ok, so I added some debug messages to list.vim:

--- a/autoload/go/list.vim
+++ b/autoload/go/list.vim
@@ -7,15 +7,20 @@ endif
 " closes the window
 function! go#list#Window(listtype, ...) abort
   let l:listtype = go#list#Type(a:listtype)
+  echom a:listtype
+  echom l:listtype
   " we don't use lwindow to close the location list as we need also the
   " ability to resize the window. So, we are going to use lopen and lclose
   " for a better user experience. If the number of errors in a current
   " location list increases/decreases, cwindow will not resize when a new
   " updated height is passed. lopen in the other hand resizes the screen.
   if !a:0 || a:1 == 0
+    echom "first if true"
     if l:listtype == "locationlist"
+      echom "closing location list"
       lclose
     else
+      echom "closing quickfix window"
       cclose
     endif
     return

And here is the output of successful build (e.g. the one that should close currently open quickfix window):

vim-go: building dispatched ...                                                                                                                               
vim-go: SUCCESS                                                                                                                                               
0                                                                                                                                                             
0                                                                                                                                                             
first if true                                                                                                                                                 
closing location list

For some reasons, even though l:listtype == 0, this condition ' if l:listtype == "locationlist"' is true.

@pborzenkov
Copy link
Contributor Author

Ok, looks like I understand what's going on here. vim casts "locationlist" to an int, since this is the type of the first comparison argument, and it becomes zero. That why the condition is true.

@pborzenkov
Copy link
Contributor Author

@fatih Ok, so I've updated the patch to use go#list#Type and also fixed the same problem (integer arguments to go#list#Window()) in jobcontrol.vim. I don't have neovim installed, so jobcontrol.vim change is untested.

@@ -99,9 +99,10 @@ function! s:on_exit(job_id, exit_status) abort

call s:callback_handlers_on_exit(s:jobs[a:job_id], a:exit_status, std_combined)

let l:listtype = go#list#Type("locationlist")
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you change this to quickfix as well? I know it was already like this before, but let us be consistent with the others as well. It also fixes #1019 as well :)

@fatih
Copy link
Owner

fatih commented Nov 24, 2016

@pborzenkov this looks good. Just a minor comment, once that is in, it's ready to be merged.

Otherwise all previous build errors are shown even after successful
build.

Fixes #1019, #1109

Signed-off-by: Pavel Borzenkov <[email protected]>
@pborzenkov
Copy link
Contributor Author

@fatih Done.

@fatih fatih merged commit cb88925 into fatih:master Nov 24, 2016
@fatih
Copy link
Owner

fatih commented Nov 24, 2016

Thanks @pborzenkov 👍

@pborzenkov pborzenkov deleted the job-ccl branch November 24, 2016 19:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants