@@ -358,9 +358,7 @@ fn vim_reviewer() -> oxi::Result<()> {
358358 let comments_in_buffer: Vec <& Comment > = review
359359 . comments
360360 . iter( )
361- . filter( |comment| {
362- comment. path == buffer_path. to_str( ) . unwrap( )
363- } )
361+ . filter( |comment| comment. path == buffer_path. to_str( ) . unwrap( ) )
364362 . collect( ) ;
365363 for comment in comments_in_buffer {
366364 let start_line = comment. start_line. unwrap_or( comment. line) ;
@@ -425,15 +423,15 @@ fn vim_reviewer() -> oxi::Result<()> {
425423
426424 // Optionally try API fetch for enrichment
427425 if let Some ( config) = get_config_from_file( )
428- && let Some ( pr_info) = fetch_pr_info_from_api( & config, pr_number) {
429- // Cache the enriched info
430- if let Ok ( json) = serde_json:: to_string( & pr_info)
431- && let Ok ( mut file) =
432- File :: create( get_pr_info_cache_path( pr_number) )
433- {
434- let _ = file. write_all( json. as_bytes( ) ) ;
435- }
426+ && let Some ( pr_info) = fetch_pr_info_from_api( & config, pr_number)
427+ {
428+ // Cache the enriched info
429+ if let Ok ( json) = serde_json:: to_string( & pr_info)
430+ && let Ok ( mut file) = File :: create( get_pr_info_cache_path( pr_number) )
431+ {
432+ let _ = file. write_all( json. as_bytes( ) ) ;
436433 }
434+ }
437435
438436 Ok ( ( ) )
439437 }
@@ -748,10 +746,11 @@ fn vim_reviewer() -> oxi::Result<()> {
748746 |_args: CommandArgs | -> ApiResult <( ) > {
749747 // Invalidate PrInfo cache so files are re-computed from git
750748 if let Some ( config) = get_config_from_file( )
751- && let Some ( pr_number) = config. active_pr {
752- let cache_path = get_pr_info_cache_path( pr_number) ;
753- let _ = std:: fs:: remove_file( & cache_path) ;
754- }
749+ && let Some ( pr_number) = config. active_pr
750+ {
751+ let cache_path = get_pr_info_cache_path( pr_number) ;
752+ let _ = std:: fs:: remove_file( & cache_path) ;
753+ }
755754 refresh_status_buffer( ) ?;
756755 Ok ( ( ) )
757756 }
@@ -992,11 +991,12 @@ fn get_files_changed(base_branch: &str) -> Result<Vec<FileChange>, String> {
992991 let mut deletions: u32 = 0 ;
993992
994993 if let Ok ( patch) = git2:: Patch :: from_diff ( & diff, idx)
995- && let Some ( ref patch) = patch {
996- let ( _, adds, dels) = patch. line_stats ( ) . unwrap_or ( ( 0 , 0 , 0 ) ) ;
997- additions = adds as u32 ;
998- deletions = dels as u32 ;
999- }
994+ && let Some ( ref patch) = patch
995+ {
996+ let ( _, adds, dels) = patch. line_stats ( ) . unwrap_or ( ( 0 , 0 , 0 ) ) ;
997+ additions = adds as u32 ;
998+ deletions = dels as u32 ;
999+ }
10001000
10011001 files. push ( FileChange {
10021002 path,
@@ -1020,14 +1020,16 @@ fn get_or_build_pr_info(config: &Config, pr_number: u32) -> Option<PrInfo> {
10201020
10211021 // Try loading from cache
10221022 if cache_path. exists ( )
1023- && let Ok ( mut file) = File :: open ( & cache_path) {
1024- let mut contents = String :: new ( ) ;
1025- if file. read_to_string ( & mut contents) . is_ok ( )
1026- && let Ok ( cached) = serde_json:: from_str :: < PrInfo > ( & contents)
1027- && cached. base_branch == base_branch {
1028- return Some ( cached) ;
1029- }
1023+ && let Ok ( mut file) = File :: open ( & cache_path)
1024+ {
1025+ let mut contents = String :: new ( ) ;
1026+ if file. read_to_string ( & mut contents) . is_ok ( )
1027+ && let Ok ( cached) = serde_json:: from_str :: < PrInfo > ( & contents)
1028+ && cached. base_branch == base_branch
1029+ {
1030+ return Some ( cached) ;
10301031 }
1032+ }
10311033
10321034 // Build locally
10331035 let files_changed = match get_files_changed ( & base_branch) {
@@ -1048,9 +1050,10 @@ fn get_or_build_pr_info(config: &Config, pr_number: u32) -> Option<PrInfo> {
10481050
10491051 // Cache to disk
10501052 if let Ok ( json) = serde_json:: to_string ( & pr_info)
1051- && let Ok ( mut file) = File :: create ( & cache_path) {
1052- let _ = file. write_all ( json. as_bytes ( ) ) ;
1053- }
1053+ && let Ok ( mut file) = File :: create ( & cache_path)
1054+ {
1055+ let _ = file. write_all ( json. as_bytes ( ) ) ;
1056+ }
10541057
10551058 Some ( pr_info)
10561059}
@@ -1269,14 +1272,15 @@ fn build_status_lines(
12691272
12701273 // Review body
12711274 if let Some ( review) = review
1272- && !review. body . is_empty ( ) {
1273- lines. push ( "Review body:" . to_string ( ) ) ;
1275+ && !review. body . is_empty ( )
1276+ {
1277+ lines. push ( "Review body:" . to_string ( ) ) ;
1278+ actions. push ( StatusLineAction :: None ) ;
1279+ for body_line in review. body . lines ( ) {
1280+ lines. push ( format ! ( " {}" , body_line) ) ;
12741281 actions. push ( StatusLineAction :: None ) ;
1275- for body_line in review. body . lines ( ) {
1276- lines. push ( format ! ( " {}" , body_line) ) ;
1277- actions. push ( StatusLineAction :: None ) ;
1278- }
12791282 }
1283+ }
12801284
12811285 ( lines, actions)
12821286}
@@ -1747,9 +1751,7 @@ impl Review {
17471751 }
17481752
17491753 // Use the backend_url from config, or default to gitlab.com
1750- let base_url = self
1751- . backend_url . as_deref ( )
1752- . unwrap_or ( "https://gitlab.com" ) ;
1754+ let base_url = self . backend_url . as_deref ( ) . unwrap_or ( "https://gitlab.com" ) ;
17531755
17541756 let encoded_project = format ! ( "{}/{}" , self . owner, self . repo) . replace ( "/" , "%2F" ) ;
17551757 let mut last_response: Option < reqwest:: blocking:: Response > = None ;
@@ -1843,15 +1845,15 @@ impl Review {
18431845 // Build position object
18441846 // For multi-line comments, use line_range instead of new_line/old_line
18451847 let mut position = serde_json:: json!( {
1846- "position_type" : "text" ,
1847- "base_sha" : base_sha,
1848- "start_sha" : start_sha,
1849- "head_sha" : head_sha,
1850- "new_path" : new_path,
1851- "old_path" : old_path,
1852- "new_line" : new_line,
1853- "old_line" : old_line,
1854- } ) ;
1848+ "position_type" : "text" ,
1849+ "base_sha" : base_sha,
1850+ "start_sha" : start_sha,
1851+ "head_sha" : head_sha,
1852+ "new_path" : new_path,
1853+ "old_path" : old_path,
1854+ "new_line" : new_line,
1855+ "old_line" : old_line,
1856+ } ) ;
18551857
18561858 // Add line_range for multi-line comments
18571859 if is_multi_line {
@@ -2127,7 +2129,7 @@ fn get_line_mapping(
21272129 let mut line_map: Vec < ( Option < u32 > , Option < u32 > ) > = Vec :: new ( ) ;
21282130
21292131 diff. foreach (
2130- & mut |_delta, _progress| { true } ,
2132+ & mut |_delta, _progress| true ,
21312133 None ,
21322134 None ,
21332135 Some ( & mut |_delta, _hunk, line| {
@@ -2157,15 +2159,17 @@ fn get_line_mapping(
21572159 if side == Side :: LEFT {
21582160 // Looking for old line number
21592161 if let Some ( old) = old_line
2160- && * old == line_number {
2161- return Ok ( ( * old_line, * new_line) ) ;
2162- }
2162+ && * old == line_number
2163+ {
2164+ return Ok ( ( * old_line, * new_line) ) ;
2165+ }
21632166 } else {
21642167 // Looking for new line number
21652168 if let Some ( new) = new_line
2166- && * new == line_number {
2167- return Ok ( ( * old_line, * new_line) ) ;
2168- }
2169+ && * new == line_number
2170+ {
2171+ return Ok ( ( * old_line, * new_line) ) ;
2172+ }
21692173 }
21702174 }
21712175
0 commit comments