-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
Show changes relative to VCS in diagnostics #467
Conversation
helix-vcs/src/lib.rs
Outdated
LineChange::Added => &"+", | ||
LineChange::RemovedAbove => &"-", | ||
LineChange::RemovedBelow => &"_", | ||
LineChange::Modified => &"~", |
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 just use the ▎
for add and modify and ▁
for blocks removed. UTF-8 characters will look better. And we can make use of colors, like green for added, yellow/orange for modified, red for removed.
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 personally prefer:
let g:gitgutter_sign_added = '▌'
let g:gitgutter_sign_removed = '▖'
let g:gitgutter_sign_removed_first_line = '▘'
let g:gitgutter_sign_modified = '▐'
let g:gitgutter_sign_modified_removed = '▞'
with
diff.plus
#35BF86
diff.minus
#F22C86
diff.delta
#6F44F0
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.
While I like those glyphs, I'm not sure if they are very discoverable to unfamiliar users. That said, I am planning to make them them theme configurable in a separate PR.
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.
▞
is confusing, I prefer -
or line like for removed, at least it's clearer.
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.
You need to see how it looks visually. ▞
is specifically when an area is both deleted and then modified.
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.
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.
Without you explaning, I won't understand what that means.
It would be good as a plugin but I think this plugin should be bundled by default, since git is very widely used. |
I wonder if https://github.com/Byron/gitoxide might be a better fit to avoid needing to link against openssl/libssh/libz. |
Can gitoxide do a line diff for file yet? Oh, maybe it can. https://docs.rs/git-diff/0.3.0/git_diff/tree/index.html |
I will look at gitoxide later; I hadn't realized it provided a goo diff alternative yet. That said; we probably won't need openssh since we don't need to make connections. (I did however forget to disable it... ;-)) |
667d30f
to
c07e7ef
Compare
c07e7ef
to
d1c25e5
Compare
In this case git, but others are easily added.
ab6ce71
to
4c4ec7b
Compare
I took a look at gitoxide, but that is still heavily in development; case in point, if I wanted to use git-repository, I had to use the git repo, and I had a conflict with libc when using git-repository, git-diff and chrono. My suggestion is to take another look after a couple of months and see if things are more stable. |
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.
Tested, seemed to show something but default colors seemed to be off. All of them is blue.
The diff also showed out too late, it will only show the current diff after two saves rather than instant after save.
if let Some(vcs) = &mut self.version_control { | ||
vcs.diff(); | ||
} |
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 the bug that the diff showed out too late is probably because save_impl
is asynchronous and this does not triggers render after it is finished.
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.
Any suggestions on how to fix this?
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.
Ok, I see now that the diff occurs before the async save call, which means it occurs before the file is actually written.
I'm not sure how to fix it in an elegant way yet, but there is progress.
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.
Sorry, forgot to comment here, I think the way to go would be to .and_then
the save future, in that closure schedule another callback (using something similar as cx.callback) and modify the document in there.
I'm planning on making this a bit easier to do by introducing hooks, so saving would trigger a hook::DOCUMENT_SAVED
and schedule jobs like these.
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 had some time to look at it again.
From what I can see, we need some way to have a job queue with access to the document and which the document can access.
I'm thinking of giving document a jobs queue. This would be similar to how Compositor polls it's layers, now Editor will poll the documents for any jobs.
This would allow us to move several other functions to async, like possibly open and format.
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 could maybe make the existing jobs queue accessible globally, and in the callback you can simply use a passed in id to find the document (editor.documents[id]
)
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.
Format already uses the callback system after some of the recent PRs, it receives the changes in a job then applies them to the doc: #285
The blue is because the scope names don't match anymore I guess. The code will use #0000FF if a scope is missing so you can see something is wrong: Line 223 in d754c72
(Maybe we should make that bright yellow/red/pink to make it more obvious) |
5c5ad45
to
b67c35e
Compare
wouldn't it be better to make another column for displaying git changes? diagnostics column is very wide. here's how it could look like: |
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.
There are color now but the issue that the displayed vcs is still one save old is still there.
for (i, line) in (view.first_line..last_line).enumerate() { | ||
use helix_core::diagnostic::Severity; | ||
if let Some(line_changes) = doc.vcs_line_changes() { |
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.
To address #405, maybe here we could abstract it to simply be doc.line_changes()
. It doesn't need to be done in this PR however.
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.
Good point, though I agree that it is probably outside of the scope of this PR.
As I mentioned above, I am still working this out.
|
I also find the column a bit too wide for my taste, however I'm glad the functionality is being worked on! |
I don't know if you found out or not, but we indeed already have this functionality: helix/helix-term/src/application.rs Lines 200 to 212 in 2f8ad7f
We already use it for opening and maybe formatting, e.g. helix/helix-term/src/commands.rs Lines 1563 to 1591 in 2f8ad7f
|
Anyone working on this? I'd really like this functionality pre plugins since the plugin system seems a bit far off. I'd be happy to help on this. |
I'll take a look then 👍 |
Should we close in favor of #1623? |
Because I'm lazy it is for git only for now, and it is only updated when the file is saved.
WIP because my children wake too early and I'm tired.