Receiving VcsUser instance
已回答
Hello everyone!
I want to get the instance of VcsUser class for:
1) user who last edited the line of code where the caret is located now
2) authorized user of this project
Now I can receive DiffContent instance for concrete line, maybe it can be helpful:
Project project = e.getProject();
Document document = e.getData(PlatformDataKeys.EDITOR).getDocument();
int offset = e.getData(PlatformDataKeys.CARET).getOffset();
int lineNumber = document.getLineNumber(offset);
TextRange textRange = DocumentUtil.getLineTextRange(document, lineNumber);
DiffContent diffContent = DiffContentFactory.getInstance().createFragment(project, document, textRange);
Can you please describe the approximate way to achieve it?
请先登录再写评论。
Spolutrean,
I have noticed that you have removed the previous thread in which we had the conversation two days before and created a new one with the same question - this is not, how it should work.
The previous thread was marked as Answered, but I still didn't have a solution.
I didn't find a way to contact you directly or remove the tag Answered.
I thought that if a post is marked as Answered, then the discussion in it is over.
I apologize for this, I asked a question in that thread and didn't get an answer. Because of this, I decided it would be better to create new ones and continue with it.
>maybe it can be helpful:
Probably, it won't be - DiffContent is used to show "diff windows".
First, you need to get registered VCS root for the file in context:
>authorized user of this project
>user who last edited the line of code where the caret is located now
You can also use GitHandler and invoke/parse `git blame` command manually. And create VcsUser with VcsUserRegistry#createUser.
Thank you a lot!
UPD: GitFileAnnotation will return data for lines in HEAD revision (just like 'git blame' does).
These might not be the same if file has uncommitted changes.
So you might need to transfer line number using