@@ -18,13 +18,13 @@ pub struct Args {
18
18
pub config_file : Option < PathBuf > ,
19
19
pub files : Vec < ( PathBuf , Position ) > ,
20
20
pub working_directory : Option < PathBuf > ,
21
- pub line_number : usize ,
22
21
}
23
22
24
23
impl Args {
25
24
pub fn parse_args ( ) -> Result < Args > {
26
25
let mut args = Args :: default ( ) ;
27
26
let mut argv = std:: env:: args ( ) . peekable ( ) ;
27
+ let mut line_number = 0 ;
28
28
29
29
argv. next ( ) ; // skip the program, we don't care about that
30
30
@@ -90,14 +90,11 @@ impl Args {
90
90
}
91
91
}
92
92
arg if arg. starts_with ( '+' ) => {
93
- let arg = arg. get ( 1 ..) . unwrap ( ) ;
94
- args . line_number = match arg. parse ( ) {
95
- Ok ( n) => n,
93
+ let arg = & arg[ 1 ..] ;
94
+ line_number = match arg. parse :: < usize > ( ) {
95
+ Ok ( n) => n. saturating_sub ( 1 ) ,
96
96
_ => anyhow:: bail!( "bad line number after +" ) ,
97
97
} ;
98
- if args. line_number > 0 {
99
- args. line_number -= 1 ;
100
- }
101
98
}
102
99
arg => args. files . push ( parse_file ( arg) ) ,
103
100
}
@@ -109,7 +106,7 @@ impl Args {
109
106
}
110
107
111
108
if let Some ( file) = args. files . first_mut ( ) {
112
- file. 1 . row = args . line_number ;
109
+ file. 1 . row = line_number;
113
110
}
114
111
115
112
Ok ( args)
0 commit comments