Add minimum column option to git inline blame (#10682)
Release Notes: - Added a setting to determine the minimum column where the inline blame information is shown. Example: `{{"git": {"inline_blame": {"min_column": 80}}}` ([#10555](https://github.com/zed-industries/zed/issues/10555)). Demo Video: https://github.com/zed-industries/zed/assets/1185253/61343dbe-9002-4bd1-b0d4-403f8da79050 --------- Co-authored-by: Thorsten Ball <mrnugget@gmail.com>
This commit is contained in:
parent
1b75f9d620
commit
bb97432e9a
3 changed files with 17 additions and 3 deletions
|
@ -2006,6 +2006,7 @@ async fn test_git_blame_is_forwarded(cx_a: &mut TestAppContext, cx_b: &mut TestA
|
||||||
let inline_blame_off_settings = Some(InlineBlameSettings {
|
let inline_blame_off_settings = Some(InlineBlameSettings {
|
||||||
enabled: false,
|
enabled: false,
|
||||||
delay_ms: None,
|
delay_ms: None,
|
||||||
|
min_column: None,
|
||||||
});
|
});
|
||||||
cx_a.update(|cx| {
|
cx_a.update(|cx| {
|
||||||
cx.update_global(|store: &mut SettingsStore, cx| {
|
cx.update_global(|store: &mut SettingsStore, cx| {
|
||||||
|
|
|
@ -45,7 +45,7 @@ use smallvec::SmallVec;
|
||||||
use std::{
|
use std::{
|
||||||
any::TypeId,
|
any::TypeId,
|
||||||
borrow::Cow,
|
borrow::Cow,
|
||||||
cmp::{self, Ordering},
|
cmp::{self, max, Ordering},
|
||||||
fmt::Write,
|
fmt::Write,
|
||||||
iter, mem,
|
iter, mem,
|
||||||
ops::Range,
|
ops::Range,
|
||||||
|
@ -1141,8 +1141,17 @@ impl EditorElement {
|
||||||
let start_x = {
|
let start_x = {
|
||||||
const INLINE_BLAME_PADDING_EM_WIDTHS: f32 = 6.;
|
const INLINE_BLAME_PADDING_EM_WIDTHS: f32 = 6.;
|
||||||
|
|
||||||
let line_width = line_layout.line.width;
|
let padded_line_width =
|
||||||
content_origin.x + line_width + (em_width * INLINE_BLAME_PADDING_EM_WIDTHS)
|
line_layout.line.width + (em_width * INLINE_BLAME_PADDING_EM_WIDTHS);
|
||||||
|
|
||||||
|
let min_column = ProjectSettings::get_global(cx)
|
||||||
|
.git
|
||||||
|
.inline_blame
|
||||||
|
.and_then(|settings| settings.min_column)
|
||||||
|
.map(|col| self.column_pixels(col as usize, cx))
|
||||||
|
.unwrap_or(px(0.));
|
||||||
|
|
||||||
|
content_origin.x + max(padded_line_width, min_column)
|
||||||
};
|
};
|
||||||
|
|
||||||
let absolute_offset = point(start_x, start_y);
|
let absolute_offset = point(start_x, start_y);
|
||||||
|
|
|
@ -79,6 +79,10 @@ pub struct InlineBlameSettings {
|
||||||
///
|
///
|
||||||
/// Default: 0
|
/// Default: 0
|
||||||
pub delay_ms: Option<u64>,
|
pub delay_ms: Option<u64>,
|
||||||
|
/// The minimum column number to show the inline blame information at
|
||||||
|
///
|
||||||
|
/// Default: 0
|
||||||
|
pub min_column: Option<u32>,
|
||||||
}
|
}
|
||||||
|
|
||||||
const fn true_value() -> bool {
|
const fn true_value() -> bool {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue