Skip to content

Commit a596115

Browse files
chschneiderChristian Schneider
authored andcommitted
Trim trailing colons from paths to allow copy/pasting git grep -n output (helix-editor#9963)
Co-authored-by: Christian Schneider <[email protected]>
1 parent 61546e7 commit a596115

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

helix-term/src/args.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ pub(crate) fn parse_file(s: &str) -> (PathBuf, Position) {
129129
///
130130
/// Does not validate if file.rs is a file or directory.
131131
fn split_path_row_col(s: &str) -> Option<(PathBuf, Position)> {
132-
let mut s = s.rsplitn(3, ':');
132+
let mut s = s.trim_end_matches(':').rsplitn(3, ':');
133133
let col: usize = s.next()?.parse().ok()?;
134134
let row: usize = s.next()?.parse().ok()?;
135135
let path = s.next()?.into();
@@ -141,7 +141,7 @@ fn split_path_row_col(s: &str) -> Option<(PathBuf, Position)> {
141141
///
142142
/// Does not validate if file.rs is a file or directory.
143143
fn split_path_row(s: &str) -> Option<(PathBuf, Position)> {
144-
let (path, row) = s.rsplit_once(':')?;
144+
let (path, row) = s.trim_end_matches(':').rsplit_once(':')?;
145145
let row: usize = row.parse().ok()?;
146146
let path = path.into();
147147
let pos = Position::new(row.saturating_sub(1), 0);

0 commit comments

Comments
 (0)