-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
feat: Inline Git Blame #13133
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
Open
nik-rev
wants to merge
52
commits into
helix-editor:master
Choose a base branch
from
nik-contrib:gix-blame
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+1,672
−331
Open
feat: Inline Git Blame #13133
Changes from 37 commits
Commits
Show all changes
52 commits
Select commit
Hold shift + click to select a range
29f4428
feat: Inline Git Blame
nik-rev 647615d
perf: optimize obtaining blame for the same line
nik-rev 07c69c1
fix: update blame when editing config
nik-rev 8f0721f
use format! instead of preallocating
nik-rev f54fdef
refactor: remove extra layer of sync
nik-rev 7478d9e
refactor: extract as variable
nik-rev 76a92af
feat: `all-lines` option for inline blame
nik-rev ac0e677
chore: appease clippy
nik-rev d34074a
perf: do not render inline blame on invisible lines
nik-rev b9f8226
refactor: remove `new_config` from EditorConfigDidChange event
nik-rev 22f9571
feat: split `inline-blame.behaviour` into two options
nik-rev a8097f1
perf: use `Vec<T>` instead of `HashMap<usize, T>`
nik-rev 00d168a
fix: funny boolean inversion
nik-rev ab56638
refactor: render inline blame in a separate Editor function
nik-rev 082ba4d
refactor: `match` over `if`
nik-rev c101f37
style: fmt
nik-rev b3b1c88
refactor: pass the `Style` instead of `Theme`
nik-rev af3b670
refactor: move expression
nik-rev 95344a9
perf: use string preallocations for string concatenation
nik-rev 1a0dad3
perf: only render inline blame for visible lines when `all-lines` is set
nik-rev e8d7e76
fix: spelling error
nik-rev c74fec4
fix?: do not block on the main thread when acquiring diff handle
nik-rev 616758e
refactor: rename macro
nik-rev 5d83e93
Merge branch 'master' into gix-blame
nik-rev 03f0883
chore: fix merge conflicts
nik-rev b31f1c7
Merge branch 'master' into gix-blame
nik-rev be5fbff
chore: resolve merge conflicts
nik-rev 7effac9
fix: only render inline blame once per line at most
nik-rev deb5897
Merge branch 'master' into gix-blame
nik-rev b8bd060
chore: fix merge conflicts
nik-rev 1ca7ee8
feat: rename config options
nik-rev 0123bac
docs: remove confusing instructions
nik-rev f1a29ee
feat: rename the `message` variable to `title`
nik-rev a859cb2
docs: change sentence
nik-rev 4eebdec
test: use renamed `commit_message`
nik-rev 00117f8
fix: use correct variable name `title` instead of `message`
nik-rev 01e9dc1
test: use correct variable name
nik-rev 9d27551
docs: improve wording
nik-rev dd1f31d
docs: improve wording
nik-rev eb559cf
docs: remove hard to understand sentence
nik-rev 92dc3ca
docs: improve wording
nik-rev e64b4fa
docs: improve wording
nik-rev 08c6650
docs: Add line breaks to paragraph + improve wording
nik-rev d00ff25
Merge branch 'master' into gix-blame
nik-rev 100ad75
chore: clarify comment
nik-rev 41cb919
feat: if you are the author, use "You" instead of name
nik-rev a476d6d
Revert "feat: if you are the author, use "You" instead of name"
nik-rev 14d4163
Merge branch 'master' into gix-blame
nik-rev 5e21b7f
fix: Cargo.lock
nik-rev 7a83e9e
feat: horizontal scroll of the current document into account when dra…
nik-rev 1c0b99d
refactor: Do not use `unwrap_or_default` on simple integer
nik-rev e5f837f
Merge branch 'master' into gix-blame
nik-rev File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,5 +3,7 @@ pub mod faccess; | |
| pub mod path; | ||
| pub mod range; | ||
| pub mod rope; | ||
| pub mod str; | ||
| pub mod time; | ||
|
|
||
| pub use range::Range; | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| /// Concatenates strings together. | ||
| /// | ||
| /// `str_concat!(a, " ", b, " ", c)` is: | ||
| /// - more performant than `format!("{a} {b} {c}")` | ||
| /// - more ergonomic than using `String::with_capacity` followed by a series of `String::push_str` | ||
| #[macro_export] | ||
| macro_rules! str_concat { | ||
| ($($value:expr),*) => {{ | ||
| // Rust does not allow using `+` as separator between value | ||
| // so we must add that at the end of everything. The `0` is necessary | ||
| // at the end so it does not end with "+ " (which would be invalid syntax) | ||
| let mut buf = String::with_capacity($($value.len() + )* 0); | ||
| $( | ||
| buf.push_str(&$value); | ||
| )* | ||
| buf | ||
| }} | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,75 @@ | ||
| use std::time::{Instant, SystemTime}; | ||
|
|
||
| use once_cell::sync::Lazy; | ||
|
|
||
| const SECOND: i64 = 1; | ||
| const MINUTE: i64 = 60 * SECOND; | ||
| const HOUR: i64 = 60 * MINUTE; | ||
| const DAY: i64 = 24 * HOUR; | ||
| const MONTH: i64 = 30 * DAY; | ||
| const YEAR: i64 = 365 * DAY; | ||
|
|
||
| /// Like `std::time::SystemTime::now()` but does not cause a syscall on every invocation. | ||
| /// | ||
| /// There is just one syscall at the start of the program, subsequent invocations are | ||
| /// much cheaper and use the monotonic clock instead of trigerring a syscall. | ||
| #[inline] | ||
| fn now() -> SystemTime { | ||
nik-rev marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| static START_INSTANT: Lazy<Instant> = Lazy::new(Instant::now); | ||
| static START_SYSTEM_TIME: Lazy<SystemTime> = Lazy::new(SystemTime::now); | ||
|
|
||
| *START_SYSTEM_TIME + START_INSTANT.elapsed() | ||
| } | ||
|
|
||
| /// Formats a timestamp into a human-readable relative time string. | ||
| /// | ||
| /// # Arguments | ||
| /// | ||
| /// * `timestamp` - A point in history. Seconds since UNIX epoch (UTC) | ||
| /// * `timezone_offset` - Timezone offset in seconds | ||
| /// | ||
| /// # Returns | ||
| /// | ||
| /// A String representing the relative time (e.g., "4 years ago", "11 months from now") | ||
| #[inline] | ||
| pub fn format_relative_time(timestamp: i64, timezone_offset: i32) -> String { | ||
nik-rev marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| let timestamp = timestamp + timezone_offset as i64; | ||
| let now = now() | ||
| .duration_since(std::time::UNIX_EPOCH) | ||
| .unwrap_or_default() | ||
| .as_secs() as i64 | ||
| + timezone_offset as i64; | ||
|
|
||
| let time_passed = now - timestamp; | ||
|
|
||
| let time_difference = time_passed.abs(); | ||
|
|
||
| let (value, unit) = if time_difference >= YEAR { | ||
| let years = time_difference / YEAR; | ||
| (years, if years == 1 { "year" } else { "years" }) | ||
| } else if time_difference >= MONTH { | ||
| let months = time_difference / MONTH; | ||
| (months, if months == 1 { "month" } else { "months" }) | ||
| } else if time_difference >= DAY { | ||
| let days = time_difference / DAY; | ||
| (days, if days == 1 { "day" } else { "days" }) | ||
| } else if time_difference >= HOUR { | ||
| let hours = time_difference / HOUR; | ||
| (hours, if hours == 1 { "hour" } else { "hours" }) | ||
| } else if time_difference >= MINUTE { | ||
| let minutes = time_difference / MINUTE; | ||
| (minutes, if minutes == 1 { "minute" } else { "minutes" }) | ||
| } else { | ||
| let seconds = time_difference / SECOND; | ||
| (seconds, if seconds == 1 { "second" } else { "seconds" }) | ||
| }; | ||
| let value = value.to_string(); | ||
|
|
||
| let label = if time_passed.is_positive() { | ||
| "ago" | ||
| } else { | ||
| "from now" | ||
| }; | ||
|
|
||
| crate::str_concat!(value, " ", unit, " ", label) | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.