[QUESTION] How to access version control log ui Follow
I want to de-select or remove the highlight for a commit.
I know there is ae.getData(VcsLogDataKeys.VCS_LOG_UI) but that requires VcsLogHighlighter for the method removeHighlighter(). How do I get VcsLogHighlighter.
Also Im not sure if that Class is what I need in order to un-highlight a commit. Can someone help me please?
Thanks in advance
Please sign in to leave a comment.
Hi, Kenneth! In short, the answer to your question would be "you can not remove highlighting for a specific commit".
In details:
Under the "Gear" button, there is a submenu "Highlight" with 3 items: "My Commits", "Merge Commits", "Current Branch". My commits are bold, merge commits are grey, commits from current branch have blue background. Each of these items corresponds to a VcsLogHighlighter instance. Plugins are not supposed to remove them, and IDEA 15 does not even have the VcsLogUi.removeHighlighter method. So, if you want to somehow alter an appearance of a commit, currently there are two options:
We did not have the need for un-highlighting some individual commits, so if you could describe a little bit more why you need this, it would be really helpful.
Hi Julia,
Thanks for the reply. Sorry I didn't check my Intellij forum notifications on my second Gmail account and forgot I posted this on the forum completely.
So my problem was the plugin I was developing was supposed to open all working copies of a commit and after it opened all the files in the file editor it would focus on the editor and not the log tab. But I wanted to handle the use case of a developer unintentionally pressing the custom shortcut a second time to open files from the same commit. In this situation the focus would be on the code editor and not the log tab (in my code) with the still highlighted commit, so it would return a 'please select a commit' message in the plugin code which is confusing as the developer/user can see that the commit is still highlighted.
Hope the explanation gives context to my question.
But saying all this, dont worry about the un-highlighting. I needed it for a plugin I was developing but didn't realise the plugin already exists natively out of the box, (F4 shortcut) for a commit.
My fault for not Googling about it but was a fun experience developing it with Java 8 for the first time nevertheless.
This is my Github plugin I submitted but withdrew after I knew it already existed. A bit embarrassing for sure haha.
Thanks so so much for the reply though, learned something either way :)
I might as well let you have a look if you are curious (hopefully). I did submit this plugin but withdrew it after I realised there was a native intellij feature already there.
https://github.com/ManiacViper/LazyDev.git
Curious if you have a Github account I can follow? I want some inspiration for coding in my spare time and I don't mind getting it from a developer from Jetbrains (I assume).
Hi, Kenneth,
Thank you for explaining your use case. I think what you might want is to deselect the commit rather than unhighlight. We use term "highlight" for describing changing appearance of specific commits, for example we use bold text for commits made by current user, and blue background for commits in the current branch. Selected commit is a commit that user selects by clicking on it or using arrow buttons.
But I do not think that deselecting a commit is appropriate for this case. You should rather implement update method in your action and check that log is available there. Like in GoToHashOrRefAction we check that a project, a log and a log ui is availabe in the context, and set action to be disabled and invisible if one of them is not. So the action can not be called when focus is not in the log. You can read this article, specifically "Setting up action’s visibility and availability" section explaining it in more details.
Also, note that getSelectedDetails method may return instances of LoadingDetails (without any useful information except hash). This happens because we do not keep all the details in memory (to many of them), but load them on demand. For your task you should use VcsDataKeys.SELECTED_CHANGES key that return the same changes as seen in changes view, they are already properly collected.
My github account is https://github.com/juliabeliaeva, you can follow if you'd like, but I can not guarantee it to be very inspirational:)
Hey Julia,
Nice one. Didn't check all the pre-existing Action classes like GoToHashOrRefAction. Very useful for what I'm doing.
Yes if the action can be disabled, that would be great. The article is useful, the update method may be the way to go for me.
Just need to think of another use for this plugin as opening working copy files in a commit already exists lol. :)
And talking about your Github account,
JetSprinkler
has me inspired already! :)
Been thinking of Raspberry Pi or Arduino.