From fcded6ce1e8544e2f040f084cf162d9efaffc8ad Mon Sep 17 00:00:00 2001 From: Christian Schneider Date: Tue, 17 Dec 2024 20:02:06 +0100 Subject: [PATCH] Trim trailing colons from paths to allow copy/pasting git grep -n output (#9963) Co-authored-by: Christian Schneider --- helix-term/src/args.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/helix-term/src/args.rs b/helix-term/src/args.rs index 0b1c9cde..853c1576 100644 --- a/helix-term/src/args.rs +++ b/helix-term/src/args.rs @@ -129,7 +129,7 @@ pub(crate) fn parse_file(s: &str) -> (PathBuf, Position) { /// /// Does not validate if file.rs is a file or directory. fn split_path_row_col(s: &str) -> Option<(PathBuf, Position)> { - let mut s = s.rsplitn(3, ':'); + let mut s = s.trim_end_matches(':').rsplitn(3, ':'); let col: usize = s.next()?.parse().ok()?; let row: usize = s.next()?.parse().ok()?; let path = s.next()?.into(); @@ -141,7 +141,7 @@ fn split_path_row_col(s: &str) -> Option<(PathBuf, Position)> { /// /// Does not validate if file.rs is a file or directory. fn split_path_row(s: &str) -> Option<(PathBuf, Position)> { - let (path, row) = s.rsplit_once(':')?; + let (path, row) = s.trim_end_matches(':').rsplit_once(':')?; let row: usize = row.parse().ok()?; let path = path.into(); let pos = Position::new(row.saturating_sub(1), 0);