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

Re-evaluate sameids after buffer is re-entered #998

Merged
merged 1 commit into from
Aug 9, 2016

Conversation

bhcleek
Copy link
Collaborator

@bhcleek bhcleek commented Aug 9, 2016

When g:go_auto_sameids is not set, re-apply :GoSameIds after the buffer
is displayed in a window. This ensures that once the user has called
:GoSameIds, the highlighting will be applied in the buffer based on the
cursor position at the time of evaluation until the user calls
:GoSameIdsClear, even if the buffer is reloaded into the same window (
e.g. :GoRename, or even reloading the file from disk manually).

When g:go_auto_sameids is not set, re-apply :GoSameIds after the buffer
is displayed in a window. This ensures that once the user has called
:GoSameIds, the highlighting will be applied in the buffer based on the
cursor position at the time of evaluation until the user calls
:GoSameIdsClear, even if the buffer is reloaded into the same window (
e.g. :GoRename, or even reloading the file from disk manually).
if get(g:, "go_auto_sameids", 0)
" re-apply SameIds at the current cursor position at the time the buffer
" is redisplayed: e.g. :edit, :GoRename, etc.
autocmd BufWinEnter <buffer> nested call go#guru#SameIds(-1)
Copy link
Owner

Choose a reason for hiding this comment

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

So this is called because we call :e inside :GoRename, which loads the buffer and thus it triggers this line right ? I wonder if there is a case that doesn't remove the trigger below.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

That's exactly right. But the nice thing about this approach, is that it will do the right thing even the user does :edit.

I don't think there's a case that fails to remove the buffer-local autocommand; the only case I could think of is when the buffer is wiped out, but in that case the buffer-local autocommand will be removed by Vim.

@fatih fatih merged commit 973724f into fatih:master Aug 9, 2016
@fatih
Copy link
Owner

fatih commented Aug 9, 2016

Alright, let us use this a little bit, if there is any errors we'll catch them up. Thanks @bhcleek 👍

@bhcleek
Copy link
Collaborator Author

bhcleek commented Aug 9, 2016

Sounds good to me! Thanks, @fatih.

@bhcleek bhcleek deleted the sameid-autocmd branch August 9, 2016 23:46
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