File tree Expand file tree Collapse file tree 2 files changed +46
-1
lines changed
asyncgit/src/sync/staging Expand file tree Collapse file tree 2 files changed +46
-1
lines changed Original file line number Diff line number Diff line change @@ -121,7 +121,9 @@ pub(crate) fn apply_selection(
121121 . trim( )
122122 ) ;
123123
124- if hunk_line. origin ( ) == '<' {
124+ if hunk_line. origin ( ) == '<'
125+ || hunk_line. origin ( ) == '>'
126+ {
125127 break ;
126128 }
127129
Original file line number Diff line number Diff line change @@ -107,6 +107,49 @@ mod test {
107107 ) ;
108108 }
109109
110+ #[ test]
111+ fn test_panic_stage_no_newline ( ) {
112+ static FILE_1 : & str = r"a = 1
113+ b = 2" ;
114+
115+ static FILE_2 : & str = r"a = 2
116+ b = 3
117+ c = 4" ;
118+
119+ let ( path, repo) = repo_init ( ) . unwrap ( ) ;
120+ let path = path. path ( ) . to_str ( ) . unwrap ( ) ;
121+
122+ write_commit_file ( & repo, "test.txt" , FILE_1 , "c1" ) ;
123+
124+ repo_write_file ( & repo, "test.txt" , FILE_2 ) . unwrap ( ) ;
125+
126+ stage_lines (
127+ path,
128+ "test.txt" ,
129+ false ,
130+ & [
131+ DiffLinePosition {
132+ old_lineno : Some ( 1 ) ,
133+ new_lineno : None ,
134+ } ,
135+ DiffLinePosition {
136+ old_lineno : Some ( 2 ) ,
137+ new_lineno : None ,
138+ } ,
139+ ] ,
140+ )
141+ . unwrap ( ) ;
142+
143+ let diff =
144+ get_diff ( path, String :: from ( "test.txt" ) , true ) . unwrap ( ) ;
145+
146+ assert_eq ! ( diff. lines, 5 ) ;
147+ assert_eq ! (
148+ diff. hunks[ 0 ] . lines[ 0 ] . content,
149+ String :: from( "@@ -1,2 +1 @@\n " )
150+ ) ;
151+ }
152+
110153 #[ test]
111154 fn test_unstage ( ) {
112155 static FILE_1 : & str = r"0
You can’t perform that action at this time.
0 commit comments