Closed dereli closed 9 months ago
Great fix! Thanks! :clap:
Guess there could be some minor overhead from piping file contents to git
(for large files at least) but probably worth it?
Personally, I have the habit of saving files on pretty much every keystroke (also to trigger auto-formatting, etc.), and rely on the staging area in git
as the "unsaved" version, but this seems like a nice complement for those who prefer file saving as a form of "commit to disk" step, and the unsaved file alive in the editor as a form of lightweight staging step.
Thanks Carl,
Guess there could be some minor overhead from piping file contents to git (for large files at least) but probably worth it?
I tested it (well on a relatively fast computer) with a file containing more than a 10000 lines, there's no considerable slowness. But it'll be slower for sure.
On the other hand, I believe I think this is dependent on Git version, I never seem to get isUnsaved
condition below will never be hit, since unsaved changes will always be uncommitted. Reverting the order might help, I will do it if I have time later the weekend.isUnsaved
.
if (isUncommitted) {
return "Not committed yet";
} else if (isUnsaved) {
return "Unsaved changes";
} else {
return defaultMessage;
}
Issue
If a file is changed with new lines added or removed, but unsaved, blame doesn't function properly.
Solution
Add current file content while running
git blame
and letgit
do its job.