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

fix missing <buffer> for debug mappings #1696

Merged
merged 2 commits into from
Apr 8, 2018

Conversation

Jagua
Copy link
Contributor

@Jagua Jagua commented Feb 28, 2018

No description provided.

@codecov-io
Copy link

codecov-io commented Feb 28, 2018

Codecov Report

Merging #1696 into master will increase coverage by 0.01%.
The diff coverage is 0%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1696      +/-   ##
==========================================
+ Coverage    19.7%   19.72%   +0.01%     
==========================================
  Files          57       57              
  Lines        4735     4746      +11     
==========================================
+ Hits          933      936       +3     
- Misses       3802     3810       +8
Flag Coverage Δ
#nvim 15.06% <0%> (-0.04%) ⬇️
#vim74 17.27% <0%> (-0.05%) ⬇️
#vim80 18.64% <0%> (+0.02%) ⬆️
Impacted Files Coverage Δ
autoload/go/debug.vim 0% <0%> (ø) ⬆️
autoload/go/lint.vim 57.3% <0%> (+0.73%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 4f9c2e9...e757eda. Read the comment docs.

@arp242
Copy link
Contributor

arp242 commented Mar 2, 2018

Thanks for your PR!

Could you explain what issue this fixes? Right now I can do:

vim a.go
:GoDebugStart
<F9>

:e b.go
<F9>
<F5>

To place a breakpoint in both a.go and b.go, which I think is useful. But with this PR I won't be able to do that any more, since the mappings are just for the a.go buffer.

Does this fix a specific error or issue? If so, then we should probably fix that, instead of making the mappings buffer-local.

@Jagua
Copy link
Contributor Author

Jagua commented Mar 2, 2018

I have fixed that issue since my first PR was incomplete.

I think that a plugin should not override GLOBAL mappings.
That is, once executing :GoDebugStart, valuable keymaps such as <F6> will remain broken when editing for other languages.

This PR fixes this issue.

@arp242
Copy link
Contributor

arp242 commented Mar 21, 2018

Thanks. The issue with this is that the mappings are, well, only available in the buffer. For example with :tabedit foo.go they won't be available. Personally I think it's useful to have that work. Same with some other cases.

I think a better fix is to not map stuff if it's already mapped:

if !hasmapto('<Plug>(go-debug-continue)')
  nmap <F5>   <Plug>(go-debug-continue)
endif
if !hasmapto('<Plug>('(go-debug-print)')
  nmap <F6>   <Plug>(go-debug-print)
endif

" ..etc..

Or only map the F-keys if it's not mapped to something else already:

if mapcheck('<F5>') is ''
  nmap <F5>   <Plug>(go-debug-continue)
endif

We could perhaps also add an option:

if get(g:, 'go_debug_map', 1) is 0
  nmap <F5>   <Plug>(go-debug-continue)
endif

You can then add let g:go_debug_map to disable the default mappings.

I don't mind making a patch, but can't really decide which option is best here.

@arp242 arp242 self-assigned this Mar 21, 2018
@fatih
Copy link
Owner

fatih commented Mar 21, 2018

I don't mind making a patch, but can't really decide which option is best here.

Making them optional with <Plug> is the correct way. That's the way to remap mappings and we already have a dedicated section of mappings and started using them since the project has started. But I think we should hold it up to the next release. It's not urgent imho.

@Jagua
Copy link
Contributor Author

Jagua commented Apr 2, 2018

For example with :tabedit foo.go they won't be available.

Hmm, my patch (second commit) works fine in my environment.
(Because, mappings are defined by autocmd in each buffer which filetype is "go".)

However, if it does not work properly, I believe it is a good idea to prepare a variable such like g:go_debug_map . Thanks.

@arp242
Copy link
Contributor

arp242 commented Apr 4, 2018

Hm, maybe I tested it wrong, but when I tried it, it didn't seem to work. I will look again later.

@fatih fatih requested a review from arp242 April 8, 2018 08:06
@arp242
Copy link
Contributor

arp242 commented Apr 8, 2018

Okay, does seem to work. Dunno what I did wrong previously.

Should still make it configurable in the future. I'll make an issue for that, but this improves things so I'll merge it as well. Thanks 👍

@arp242 arp242 merged commit 6cd2269 into fatih:master Apr 8, 2018
arp242 added a commit that referenced this pull request Apr 8, 2018
@Jagua Jagua deleted the fix_missing_buffer_for_godebug branch April 9, 2018 15:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants