@@ -29,7 +29,7 @@ use crate::config::Config;
29
29
use crate :: delta:: { self , State , StateMachine } ;
30
30
use crate :: features;
31
31
use crate :: paint:: Painter ;
32
- use crate :: style:: { DecorationStyle , Style } ;
32
+ use crate :: style:: DecorationStyle ;
33
33
34
34
impl < ' a > StateMachine < ' a > {
35
35
#[ inline]
@@ -170,12 +170,7 @@ fn write_hunk_header(
170
170
let file_with_line_number = get_painted_file_with_line_number ( line_numbers, plus_file, config) ;
171
171
172
172
if !line. is_empty ( ) || !file_with_line_number. is_empty ( ) {
173
- write_to_output_buffer (
174
- & file_with_line_number,
175
- line,
176
- config. hunk_header_style ,
177
- painter,
178
- ) ;
173
+ write_to_output_buffer ( & file_with_line_number, line, painter, config) ;
179
174
draw_fn (
180
175
painter. writer ,
181
176
& painter. output_buffer ,
@@ -196,11 +191,6 @@ fn get_painted_file_with_line_number(
196
191
config : & Config ,
197
192
) -> String {
198
193
let mut file_with_line_number = Vec :: new ( ) ;
199
- let hunk_label;
200
- if config. navigate {
201
- hunk_label = format ! ( "{} " , config. hunk_label) ;
202
- file_with_line_number. push ( config. hunk_header_file_style . paint ( & hunk_label) ) ;
203
- }
204
194
let plus_line_number = line_numbers[ line_numbers. len ( ) - 1 ] . 0 ;
205
195
if config. hunk_header_style_include_file_path {
206
196
file_with_line_number. push ( config. hunk_header_file_style . paint ( plus_file) )
@@ -235,16 +225,23 @@ fn get_painted_file_with_line_number(
235
225
fn write_to_output_buffer (
236
226
file_with_line_number : & str ,
237
227
line : String ,
238
- style : Style ,
239
228
painter : & mut Painter ,
229
+ config : & Config ,
240
230
) {
231
+ if config. navigate {
232
+ let _ = write ! (
233
+ & mut painter. output_buffer,
234
+ "{} " ,
235
+ config. hunk_header_file_style. paint( & config. hunk_label)
236
+ ) ;
237
+ }
241
238
if !file_with_line_number. is_empty ( ) {
242
239
let _ = write ! ( & mut painter. output_buffer, "{}: " , file_with_line_number) ;
243
240
}
244
241
if !line. is_empty ( ) {
245
242
painter. syntax_highlight_and_paint_line (
246
243
& line,
247
- style ,
244
+ config . hunk_header_style ,
248
245
delta:: State :: HunkHeader ( "" . to_owned ( ) , "" . to_owned ( ) ) ,
249
246
false ,
250
247
) ;
0 commit comments