Skip to content

Commit

Permalink
Move blame to CallingProcess (dandavison#1803)
Browse files Browse the repository at this point in the history
Signed-off-by: dvermd <[email protected]>
  • Loading branch information
dvermd committed Sep 15, 2024
1 parent c384eed commit aa78604
Show file tree
Hide file tree
Showing 2 changed files with 161 additions and 163 deletions.
12 changes: 9 additions & 3 deletions src/handlers/blame.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ use crate::format::{self, FormatStringSimple, Placeholder};
use crate::format::{make_placeholder_regex, parse_line_number_format};
use crate::paint::{self, BgShouldFill, StyleSectionSpecifier};
use crate::style::Style;
use crate::utils;
use crate::utils::process;

#[derive(Clone, Debug)]
pub enum BlameLineNumbers {
Expand Down Expand Up @@ -77,8 +77,7 @@ impl<'a> StateMachine<'a> {

// Emit syntax-highlighted code
if matches!(self.state, State::Unknown) {
self.painter
.set_syntax(utils::process::git_blame_filename().as_deref());
self.painter.set_syntax(self.get_filename().as_deref());
self.painter.set_highlighter();
}
self.state = State::Blame(key);
Expand All @@ -94,6 +93,13 @@ impl<'a> StateMachine<'a> {
Ok(handled_line)
}

fn get_filename(&self) -> Option<String> {
match &*process::calling_process() {
process::CallingProcess::GitBlame(command_line) => command_line.last_arg.clone(),
_ => None,
}
}

fn blame_metadata_style(
&mut self,
key: &str,
Expand Down
Loading

0 comments on commit aa78604

Please sign in to comment.