-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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 a rename #975
Conversation
Hi @bhcleek. To be honest I didn't like this. I don't want that a feature is called because of other commands. If you really want this you should create custom vim function in your |
@fatih I think you may have misunderstood what this change does. It doesn't unconditionally highlight the identifier under the cursor after a rename; it only highlights the identifier under the cursor if it was already highlighted before the rename. Perhaps a demonstration will help: With this patch, the behavior is: The behavior on master seems wrong to me. The user has highlighted the identifier under the cursor and then renamed it. After renaming, I would expect the identifier under the cursor to be highlighted, but on master the length of the previous name of the identifier under the cursor has determined the highlight length. |
@bhcleek upon rethinking I think you are right. We can make vim-go a little bit smarter. Even though I believe it's the user's responsibility to clear before renaming, I assume there will be a lot of people doing this. It can't merged though, can you please rebase against master again ? |
caeddbb
to
5aa1e3d
Compare
PTAL I'm not entirely sure the technique I've employed here is the right one. |
@@ -72,6 +72,8 @@ function! go#rename#Rename(bang, ...) | |||
" we need a way to get the list of changes from gorename upon an success | |||
" change. | |||
silent execute ":e" | |||
|
|||
call go#guru#SameIdRenamed() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should do it different. There should be a function called go#guru#HasSameId()
which returns a true if it's been highlighted. And then you call it like this:
if go#guru#HasSameId()
" Call sameids again to redraw the highlighting
call go#guru#SameIds(-1)
endif
Does this makes sense? I didn't like the SameIdRenamed()
function so I would be happy if you can remove it.
@bhcleek what do you have in mind? If you can show me a working example (maybe a different PR) I can take a look. |
After working up the other approach, I definitely like it better. It's a cleaner implementation and ensures the highlighting is applied correctly in a greater range of scenarios. I'm closing this in favor of #998. |
Re-evaluate sameids after a rename. This is especially useful when
go:go_auto_sameids
is not set.