Skip to content

Commit

Permalink
only call inject_42h on *.c/*.h files
Browse files Browse the repository at this point in the history
  • Loading branch information
DavidLee18 committed Nov 1, 2024
1 parent ec07d2c commit b257712
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ macro_rules! diag_on_event {
Ok(params) => {
eprintln!("got document notification: {params:?}");
match $option {
Ok(Ok(ref op)) => {
Ok(Ok(ref op)) if is_valid_ext(params.text_document.uri.path().to_string().split(".").last().unwrap()) => {
let output = process::Command::new(&op.path)
.args([
"--name",
Expand All @@ -56,7 +56,8 @@ macro_rules! diag_on_event {
if !output.status.success() {
eprintln!("{}", String::from_utf8(output.stderr).unwrap());
}
}
},
Ok(Ok(_)) => {},
Err(ref e) => eprintln!("{e}"),
Ok(Err(ref e)) => eprintln!("{e}"),
}
Expand Down Expand Up @@ -117,6 +118,8 @@ macro_rules! send_diagnostics {
};
}

fn is_valid_ext(s: &str) -> bool { s == "c" || s == "h" }

fn read_norminette(path: &Path, text: Option<String>) -> io::Result<Vec<Diagnostic>> {
let mut cmd = process::Command::new("norminette");
match text {
Expand Down

0 comments on commit b257712

Please sign in to comment.