Unnamed repository; edit this file 'description' to name the repository.
Trim trailing colons from paths to allow copy/pasting git grep -n output (#9963)
Co-authored-by: Christian Schneider <[email protected]>
Christian Schneider 2024-12-18
parent 1badd9e · commit fcded6c
-rw-r--r--helix-term/src/args.rs4
1 files 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);