Skip to content

Commit 9bdf9ac

Browse files
committed
chore: clean up
chore: remove unused import _
1 parent ddf8ac1 commit 9bdf9ac

File tree

6 files changed

+8
-81
lines changed

6 files changed

+8
-81
lines changed

helix-term/src/commands/typed.rs

-34
Original file line numberDiff line numberDiff line change
@@ -70,29 +70,6 @@ impl CommandCompleter {
7070
}
7171
}
7272

73-
fn blame(cx: &mut compositor::Context, _args: Args, event: PromptEvent) -> anyhow::Result<()> {
74-
if event != PromptEvent::Validate {
75-
return Ok(());
76-
}
77-
78-
let (view, doc) = current_ref!(cx.editor);
79-
let text = doc.text();
80-
let selection = doc.selection(view.id);
81-
let cursor_line = text.char_to_line(selection.primary().cursor(doc.text().slice(..)));
82-
let result = cx
83-
.editor
84-
.diff_providers
85-
.blame_line(doc.path().context("Not in a file")?, cursor_line.try_into()?)
86-
.inspect_err(|err| {
87-
log::error!("Could not get blame: {err}");
88-
})
89-
.context("No blame information")?;
90-
91-
cx.editor.set_status(result.to_string());
92-
93-
Ok(())
94-
}
95-
9673
fn quit(cx: &mut compositor::Context, _args: Args, event: PromptEvent) -> anyhow::Result<()> {
9774
log::debug!("quitting...");
9875

@@ -3578,17 +3555,6 @@ pub const TYPABLE_COMMAND_LIST: &[TypableCommand] = &[
35783555
..Signature::DEFAULT
35793556
},
35803557
},
3581-
TypableCommand {
3582-
name: "blame-line-range",
3583-
aliases: &["blame"],
3584-
doc: "Blames a range of lines. No args: Blame selection. 1 arg: Blame line. 2 args: Represents (from, to) line range to git blame.",
3585-
fun: blame,
3586-
completer: CommandCompleter::none(),
3587-
signature: Signature {
3588-
positionals: (0, Some(2)),
3589-
..Signature::DEFAULT
3590-
},
3591-
},
35923558
];
35933559

35943560
pub static TYPABLE_COMMAND_MAP: Lazy<HashMap<&'static str, &'static TypableCommand>> =

helix-term/src/handlers/blame.rs

+1-10
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
use helix_core::text_annotations::InlineAnnotation;
21
use helix_event::{register_hook, send_blocking};
32
use helix_view::{
43
handlers::{BlameEvent, Handlers},
@@ -57,18 +56,10 @@ fn request_git_blame(editor: &mut Editor) {
5756
return;
5857
};
5958

60-
// gix-blame expects a 1-based line
59+
// 0-based into 1-based line number
6160
let Ok(output) = editor.diff_providers.blame_line(file, cursor_line + 1) else {
6261
return;
6362
};
6463

6564
doc.blame = Some(output.to_string());
66-
// doc.blame = Some(vec![InlineAnnotation::new(
67-
// text.try_line_to_char(cursor_lin + 1)
68-
// .unwrap_or(text.len_chars())
69-
// // to get the last position in the current line
70-
// - 1,
71-
// output.to_string(),
72-
// )]);
73-
// log::error!("{:?}", doc.blame);
7465
}

helix-term/src/ui/text_decorations/blame.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@ impl Decoration for EolBlame<'_> {
4141
let style = self.style;
4242
let width = renderer.viewport.width;
4343
let start_col = col - renderer.offset.col as u16;
44-
// start drawing the git blame 1 space after the end of the line
45-
let draw_col = col + 1;
44+
// start drawing the git blame 6 spaces after the end of the line
45+
let draw_col = col + 6;
4646

4747
let end_col = renderer
4848
.column_in_bounds(draw_col as usize, 1)

helix-term/src/ui/text_decorations/diagnostics.rs

+2-29
Original file line numberDiff line numberDiff line change
@@ -271,41 +271,14 @@ impl Decoration for InlineDiagnostics<'_> {
271271
DiagnosticFilter::Disable => None,
272272
};
273273
if let Some((eol_diagnostic, _)) = eol_diagnostic {
274-
let renderer = Renderer {
274+
let mut renderer = Renderer {
275275
renderer,
276276
first_row: pos.visual_line,
277277
row: pos.visual_line,
278278
config: &self.state.config,
279279
styles: &self.styles,
280280
};
281-
// let ref mut this = renderer;
282-
let row = pos.visual_line;
283-
let col = virt_off.col;
284-
let style = renderer.styles.severity_style(eol_diagnostic.severity());
285-
let width = renderer.renderer.viewport.width;
286-
let start_col = (col - renderer.renderer.offset.col) as u16;
287-
let mut end_col = start_col;
288-
let mut draw_col = (col + 1) as u16;
289-
290-
for line in eol_diagnostic.message.lines() {
291-
if !renderer.renderer.column_in_bounds(draw_col as usize, 1) {
292-
break;
293-
}
294-
295-
(end_col, _) = renderer.renderer.set_string_truncated(
296-
renderer.renderer.viewport.x + draw_col,
297-
row,
298-
line,
299-
width.saturating_sub(draw_col) as usize,
300-
|_| style,
301-
true,
302-
false,
303-
);
304-
305-
draw_col = end_col - renderer.renderer.viewport.x + 2; // double space between lines
306-
}
307-
308-
col_off = end_col - start_col;
281+
col_off = renderer.draw_eol_diagnostic(eol_diagnostic, pos.visual_line, virt_off.col);
309282
}
310283

311284
self.state.compute_line_diagnostics();

helix-vcs/src/git.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ impl fmt::Display for BlameInformation {
137137
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
138138
write!(
139139
f,
140-
"{} {} • {} • {}",
140+
"{}, {} • {} • {}",
141141
self.author_name, self.commit_date, self.commit_message, self.commit_hash
142142
)
143143
}

helix-vcs/src/lib.rs

+2-5
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,8 @@ impl DiffProviderRegistry {
4949
})
5050
}
5151

52-
pub fn blame_line(
53-
&self,
54-
file: &Path,
55-
line: u32,
56-
) -> anyhow::Result<BlameInformation> {
52+
/// Blame line in a file. Lines are 1-indexed
53+
pub fn blame_line(&self, file: &Path, line: u32) -> anyhow::Result<BlameInformation> {
5754
self.providers
5855
.iter()
5956
.map(|provider| provider.blame_line(file, line))

0 commit comments

Comments
 (0)