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

debug: add explicit preserve layout setting #3125

Merged
merged 3 commits into from
Jan 17, 2021

Conversation

holycacao
Copy link
Contributor

Adds a new setting, g:go_debug_preserve_layout, which, when explicitly set, will preserve the current window layout, irrespective of the value of g:go_debug_windows. Default value keeps current behavior (does not preserve). Fixes #3020.

silent! exe bufwinnr(bufnr('__GODEBUG_OUTPUT__')) 'wincmd c'
silent! exe bufwinnr(bufnr('__GODEBUG_GOROUTINES__')) 'wincmd c'

let stackbufnr = bufnr('__GODEBUG_STACKTRACE__')
Copy link
Contributor Author

@holycacao holycacao Dec 31, 2020

Choose a reason for hiding this comment

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

without this change, plugin windows were getting closed when g:go_debug_windows was set to {}

@@ -211,6 +211,10 @@ function! go#config#DebugWindows() abort

endfunction

function! go#config#DebugPreserveLayout() abort
return get(g:, 'go_debug_preserve_layout', -1)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Please make the default value 0, as the documentation you added indicates it should be.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

see comment below

@@ -441,7 +457,8 @@ endfunction
function! s:start_cb() abort
let l:winid = win_getid()
let l:debugwindows = go#config#DebugWindows()
if !empty(l:debugwindows)
let l:debugpreservelayout = go#config#DebugPreserveLayout()
if (empty(l:debugwindows) && l:debugpreservelayout == -1) || l:debugpreservelayout != 1
Copy link
Collaborator

Choose a reason for hiding this comment

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

if empty(l:debugwindows) || l:debugpreservelayout

Copy link
Contributor Author

Choose a reason for hiding this comment

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

this is the condition for calling only ie not preserving the layout, so it needs to be flipped. i left off the ! on empty( and fixed that tho


Preserve window layout in debugging mode. If explicitly set, it will override
the preserving behavior when |'g:go_debug_windows'| is empty.
>
Copy link
Collaborator

Choose a reason for hiding this comment

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

As worded, this sounds like the inverse of what it does. I believe it should indicate that it preserves window layout in debugging mode regardless of the value of g:go_debug_windows.

Also, there should be no need for a user to explicitly set it. Making the default value 0 should be sufficient and results in a user experience consistent with how vim-go works.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I agree that the wording can be improved. However, a default of 0 would conflict with setting g:go_debug_windows = {} and break backwards compatibility.

The problem is this new setting controls the same window option (:only) as g:go_debug_windows, so there needs to be a way to determine precedence when their values indicate conflicting behavior. The default value of -1 (unset) makes this new setting backwards compatible because -1 means defer to g:go_debug_windows for :only behavior ie if g:go_debug_windows is empty, preserve layout. If not -1, the user explicitly set the value and it should take precedence.

This also allows it to work in conjunction with g:go_debug_windows - a user can set g:go_debug_windows = {} and g:go_debug_preserve_layout = 0, which would not display any debug windows and also not preserve their layout (I'm not sure why someone would want this, but the settings behavior would be consistent nonetheless).

g:go_debug_windows g:go_debug_preserve_layout only
{} -1 noonly
{} 0 only
{} 1 noonly
non-empty -1 only
non-empty 0 only
non-empty 1 noonly

Copy link
Collaborator

Choose a reason for hiding this comment

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

I think there was a typo in my original request. The logic should be if !(empty(l:debugwindows) || l:debugpreservelayout). With that, there's no need to determine whether g:go_debug_preserve_layout was explicitly set.

When go#config#DebugWindows() returns an empty dict, then the current behavior on master is correct and should be preserved: only is not used. What you've asked for is a way to also skip only when l:debugwindows is not empty; the option you've introduced is useful for that purpose, but there's no need to determine whether the user explicitly set it; it only needs to be considered when l:debugwindows is not empty.

g:go_debug_windows g:go_debug_preserve_layout only
{} 0 noonly
{} 1 noonly
non-empty 0 only
non-empty 1 noonly

i.e. g:go_debug_preserve_layout should only be considered when l:debugwindows is not empty.

@holycacao
Copy link
Contributor Author

I don't understand the test failures. Looks like maybe a temporary test runner problem?

@bhcleek
Copy link
Collaborator

bhcleek commented Jan 2, 2021

That one failure looks like it was a problem with a flaky test. I've re-run them all.

Thanks for contributing to vim-go!

@bhcleek bhcleek added this to the vim-go 1.25 milestone Jan 2, 2021
bhcleek added a commit that referenced this pull request Jan 17, 2021
@bhcleek bhcleek merged commit 3a8e3f6 into fatih:master Jan 17, 2021
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.

Debugger caused the quitting of some other plugins
2 participants