chore: clean up
chore: remove unused import _
This commit is contained in:
parent
ddf8ac1158
commit
9bdf9ac941
6 changed files with 8 additions and 81 deletions
|
@ -70,29 +70,6 @@ impl CommandCompleter {
|
|||
}
|
||||
}
|
||||
|
||||
fn blame(cx: &mut compositor::Context, _args: Args, event: PromptEvent) -> anyhow::Result<()> {
|
||||
if event != PromptEvent::Validate {
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
let (view, doc) = current_ref!(cx.editor);
|
||||
let text = doc.text();
|
||||
let selection = doc.selection(view.id);
|
||||
let cursor_line = text.char_to_line(selection.primary().cursor(doc.text().slice(..)));
|
||||
let result = cx
|
||||
.editor
|
||||
.diff_providers
|
||||
.blame_line(doc.path().context("Not in a file")?, cursor_line.try_into()?)
|
||||
.inspect_err(|err| {
|
||||
log::error!("Could not get blame: {err}");
|
||||
})
|
||||
.context("No blame information")?;
|
||||
|
||||
cx.editor.set_status(result.to_string());
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn quit(cx: &mut compositor::Context, _args: Args, event: PromptEvent) -> anyhow::Result<()> {
|
||||
log::debug!("quitting...");
|
||||
|
||||
|
@ -3578,17 +3555,6 @@ pub const TYPABLE_COMMAND_LIST: &[TypableCommand] = &[
|
|||
..Signature::DEFAULT
|
||||
},
|
||||
},
|
||||
TypableCommand {
|
||||
name: "blame-line-range",
|
||||
aliases: &["blame"],
|
||||
doc: "Blames a range of lines. No args: Blame selection. 1 arg: Blame line. 2 args: Represents (from, to) line range to git blame.",
|
||||
fun: blame,
|
||||
completer: CommandCompleter::none(),
|
||||
signature: Signature {
|
||||
positionals: (0, Some(2)),
|
||||
..Signature::DEFAULT
|
||||
},
|
||||
},
|
||||
];
|
||||
|
||||
pub static TYPABLE_COMMAND_MAP: Lazy<HashMap<&'static str, &'static TypableCommand>> =
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
use helix_core::text_annotations::InlineAnnotation;
|
||||
use helix_event::{register_hook, send_blocking};
|
||||
use helix_view::{
|
||||
handlers::{BlameEvent, Handlers},
|
||||
|
@ -57,18 +56,10 @@ fn request_git_blame(editor: &mut Editor) {
|
|||
return;
|
||||
};
|
||||
|
||||
// gix-blame expects a 1-based line
|
||||
// 0-based into 1-based line number
|
||||
let Ok(output) = editor.diff_providers.blame_line(file, cursor_line + 1) else {
|
||||
return;
|
||||
};
|
||||
|
||||
doc.blame = Some(output.to_string());
|
||||
// doc.blame = Some(vec![InlineAnnotation::new(
|
||||
// text.try_line_to_char(cursor_lin + 1)
|
||||
// .unwrap_or(text.len_chars())
|
||||
// // to get the last position in the current line
|
||||
// - 1,
|
||||
// output.to_string(),
|
||||
// )]);
|
||||
// log::error!("{:?}", doc.blame);
|
||||
}
|
||||
|
|
|
@ -41,8 +41,8 @@ impl Decoration for EolBlame<'_> {
|
|||
let style = self.style;
|
||||
let width = renderer.viewport.width;
|
||||
let start_col = col - renderer.offset.col as u16;
|
||||
// start drawing the git blame 1 space after the end of the line
|
||||
let draw_col = col + 1;
|
||||
// start drawing the git blame 6 spaces after the end of the line
|
||||
let draw_col = col + 6;
|
||||
|
||||
let end_col = renderer
|
||||
.column_in_bounds(draw_col as usize, 1)
|
||||
|
|
|
@ -271,41 +271,14 @@ impl Decoration for InlineDiagnostics<'_> {
|
|||
DiagnosticFilter::Disable => None,
|
||||
};
|
||||
if let Some((eol_diagnostic, _)) = eol_diagnostic {
|
||||
let renderer = Renderer {
|
||||
let mut renderer = Renderer {
|
||||
renderer,
|
||||
first_row: pos.visual_line,
|
||||
row: pos.visual_line,
|
||||
config: &self.state.config,
|
||||
styles: &self.styles,
|
||||
};
|
||||
// let ref mut this = renderer;
|
||||
let row = pos.visual_line;
|
||||
let col = virt_off.col;
|
||||
let style = renderer.styles.severity_style(eol_diagnostic.severity());
|
||||
let width = renderer.renderer.viewport.width;
|
||||
let start_col = (col - renderer.renderer.offset.col) as u16;
|
||||
let mut end_col = start_col;
|
||||
let mut draw_col = (col + 1) as u16;
|
||||
|
||||
for line in eol_diagnostic.message.lines() {
|
||||
if !renderer.renderer.column_in_bounds(draw_col as usize, 1) {
|
||||
break;
|
||||
}
|
||||
|
||||
(end_col, _) = renderer.renderer.set_string_truncated(
|
||||
renderer.renderer.viewport.x + draw_col,
|
||||
row,
|
||||
line,
|
||||
width.saturating_sub(draw_col) as usize,
|
||||
|_| style,
|
||||
true,
|
||||
false,
|
||||
);
|
||||
|
||||
draw_col = end_col - renderer.renderer.viewport.x + 2; // double space between lines
|
||||
}
|
||||
|
||||
col_off = end_col - start_col;
|
||||
col_off = renderer.draw_eol_diagnostic(eol_diagnostic, pos.visual_line, virt_off.col);
|
||||
}
|
||||
|
||||
self.state.compute_line_diagnostics();
|
||||
|
|
|
@ -137,7 +137,7 @@ impl fmt::Display for BlameInformation {
|
|||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
write!(
|
||||
f,
|
||||
"{} • {} • {} • {}",
|
||||
"{}, {} • {} • {}",
|
||||
self.author_name, self.commit_date, self.commit_message, self.commit_hash
|
||||
)
|
||||
}
|
||||
|
|
|
@ -49,11 +49,8 @@ impl DiffProviderRegistry {
|
|||
})
|
||||
}
|
||||
|
||||
pub fn blame_line(
|
||||
&self,
|
||||
file: &Path,
|
||||
line: u32,
|
||||
) -> anyhow::Result<BlameInformation> {
|
||||
/// Blame line in a file. Lines are 1-indexed
|
||||
pub fn blame_line(&self, file: &Path, line: u32) -> anyhow::Result<BlameInformation> {
|
||||
self.providers
|
||||
.iter()
|
||||
.map(|provider| provider.blame_line(file, line))
|
||||
|
|
Loading…
Add table
Reference in a new issue