-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Accept +num flag for opening at line number #5603
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -17,6 +17,7 @@ pub struct Args { | |||||||||||||||||||||||
pub log_file: Option<PathBuf>, | ||||||||||||||||||||||||
pub config_file: Option<PathBuf>, | ||||||||||||||||||||||||
pub files: Vec<(PathBuf, Position)>, | ||||||||||||||||||||||||
pub line_number: usize, | ||||||||||||||||||||||||
} | ||||||||||||||||||||||||
|
||||||||||||||||||||||||
impl Args { | ||||||||||||||||||||||||
|
@@ -73,6 +74,16 @@ impl Args { | |||||||||||||||||||||||
} | ||||||||||||||||||||||||
} | ||||||||||||||||||||||||
} | ||||||||||||||||||||||||
arg if arg.starts_with('+') => { | ||||||||||||||||||||||||
let arg = arg.get(1..).unwrap(); | ||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This can also be cleaned up a little: |
||||||||||||||||||||||||
args.line_number = match arg.parse() { | ||||||||||||||||||||||||
Ok(n) => n, | ||||||||||||||||||||||||
_ => anyhow::bail!("bad line number after +"), | ||||||||||||||||||||||||
}; | ||||||||||||||||||||||||
if args.line_number > 0 { | ||||||||||||||||||||||||
args.line_number -= 1; | ||||||||||||||||||||||||
} | ||||||||||||||||||||||||
Comment on lines
+79
to
+85
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||||||||||
} | ||||||||||||||||||||||||
arg => args.files.push(parse_file(arg)), | ||||||||||||||||||||||||
} | ||||||||||||||||||||||||
} | ||||||||||||||||||||||||
|
@@ -82,6 +93,10 @@ impl Args { | |||||||||||||||||||||||
args.files.push(parse_file(&arg)); | ||||||||||||||||||||||||
} | ||||||||||||||||||||||||
|
||||||||||||||||||||||||
if let Some(file) = args.files.first_mut() { | ||||||||||||||||||||||||
file.1.row = args.line_number; | ||||||||||||||||||||||||
} | ||||||||||||||||||||||||
|
||||||||||||||||||||||||
Ok(args) | ||||||||||||||||||||||||
} | ||||||||||||||||||||||||
} | ||||||||||||||||||||||||
|
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -73,6 +73,7 @@ FLAGS: | |||||
-V, --version Prints version information | ||||||
--vsplit Splits all given files vertically into different windows | ||||||
--hsplit Splits all given files horizontally into different windows | ||||||
+N Goto line number N | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
", | ||||||
env!("CARGO_PKG_NAME"), | ||||||
VERSION_AND_GIT_HASH, | ||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like this isn't used outside of the
parse_args
function so it could be a local in that function:let mut line_number = 0;