aboutsummaryrefslogtreecommitdiff
path: root/helix-term/src/args.rs
diff options
context:
space:
mode:
Diffstat (limited to 'helix-term/src/args.rs')
-rw-r--r--helix-term/src/args.rs14
1 files changed, 14 insertions, 0 deletions
diff --git a/helix-term/src/args.rs b/helix-term/src/args.rs
index f782539c..6a49889b 100644
--- a/helix-term/src/args.rs
+++ b/helix-term/src/args.rs
@@ -24,6 +24,7 @@ impl Args {
pub fn parse_args() -> Result<Args> {
let mut args = Args::default();
let mut argv = std::env::args().peekable();
+ let mut line_number = 0;
argv.next(); // skip the program, we don't care about that
@@ -88,6 +89,13 @@ impl Args {
}
}
}
+ arg if arg.starts_with('+') => {
+ let arg = &arg[1..];
+ line_number = match arg.parse::<usize>() {
+ Ok(n) => n.saturating_sub(1),
+ _ => anyhow::bail!("bad line number after +"),
+ };
+ }
arg => args.files.push(parse_file(arg)),
}
}
@@ -97,6 +105,12 @@ impl Args {
args.files.push(parse_file(&arg));
}
+ if let Some(file) = args.files.first_mut() {
+ if line_number != 0 {
+ file.1.row = line_number;
+ }
+ }
+
Ok(args)
}
}