tenseleyflow/fackr / fedcc84

Browse files

feat: arrow keys at file bounds move to line start/end

Authored by mfwolffe <wolffemf@dukes.jmu.edu>
SHA
fedcc8425799cf397e0e36fa452db05a9c2c33cd
Parents
2d68717
Tree
f2fab5f

1 changed file

StatusFile+-
M src/editor/state.rs 7 0
src/editor/state.rsmodified
@@ -2249,6 +2249,9 @@ impl Editor {
22492249
                 let line_len = line_lens.get(new_line).copied().unwrap_or(0);
22502250
                 let new_col = cursor.desired_col.min(line_len);
22512251
                 cursor.move_to(new_line, new_col, extend_selection);
2252
+            } else {
2253
+                // On first line, move to start of line
2254
+                cursor.move_to(0, 0, extend_selection);
22522255
             }
22532256
         }
22542257
         self.cursors_mut().merge_overlapping();
@@ -2264,6 +2267,10 @@ impl Editor {
22642267
                 let line_len = line_lens.get(new_line).copied().unwrap_or(0);
22652268
                 let new_col = cursor.desired_col.min(line_len);
22662269
                 cursor.move_to(new_line, new_col, extend_selection);
2270
+            } else {
2271
+                // On last line, move to end of line
2272
+                let line_len = line_lens.get(cursor.line).copied().unwrap_or(0);
2273
+                cursor.move_to(cursor.line, line_len, extend_selection);
22672274
             }
22682275
         }
22692276
         self.cursors_mut().merge_overlapping();