feat: add repeat argument to delete_line
This commit is contained in:
		
							parent
							
								
									fc8642768d
								
							
						
					
					
						commit
						21d1555aca
					
				
					 1 changed files with 15 additions and 11 deletions
				
			
		|  | @ -3015,22 +3015,26 @@ pub const Editor = struct { | ||||||
|     } |     } | ||||||
|     pub const delete_to_end_meta: Meta = .{ .description = "Delete to end of line" }; |     pub const delete_to_end_meta: Meta = .{ .description = "Delete to end of line" }; | ||||||
| 
 | 
 | ||||||
|     pub fn delete_line(self: *Self, _: Context) Result { |     pub fn delete_line(self: *Self, ctx: Context) Result { | ||||||
|         const b = try self.buf_for_update(); |         const b = try self.buf_for_update(); | ||||||
|         var root = b.root; |         var root = b.root; | ||||||
|         for (self.cursels.items) |*cursel_| if (cursel_.*) |*cursel| { |         var repeat: usize = 1; | ||||||
|             const col = cursel.cursor.col; |         _ = ctx.args.match(.{tp.extract(&repeat)}) catch false; | ||||||
|             const target = cursel.cursor.target; |         while (repeat > 0) : (repeat -= 1) { | ||||||
|             try self.select_line_at_cursor(root, cursel, .include_eol); |             for (self.cursels.items) |*cursel_| if (cursel_.*) |*cursel| { | ||||||
|             root = try self.delete_selection(root, cursel, b.allocator); |                 const col = cursel.cursor.col; | ||||||
|             cursel.cursor.col = col; |                 const target = cursel.cursor.target; | ||||||
|             cursel.cursor.target = target; |                 try self.select_line_at_cursor(root, cursel, .include_eol); | ||||||
|             cursel.cursor.clamp_to_buffer(root, self.metrics); |                 root = try self.delete_selection(root, cursel, b.allocator); | ||||||
|         }; |                 cursel.cursor.col = col; | ||||||
|  |                 cursel.cursor.target = target; | ||||||
|  |                 cursel.cursor.clamp_to_buffer(root, self.metrics); | ||||||
|  |             }; | ||||||
|  |         } | ||||||
|         try self.update_buf(root); |         try self.update_buf(root); | ||||||
|         self.clamp(); |         self.clamp(); | ||||||
|     } |     } | ||||||
|     pub const delete_line_meta: Meta = .{ .description = "Delete current line" }; |     pub const delete_line_meta: Meta = .{ .description = "Delete current line", .arguments = &.{.integer} }; | ||||||
| 
 | 
 | ||||||
|     pub fn cut_to_end_vim(self: *Self, _: Context) Result { |     pub fn cut_to_end_vim(self: *Self, _: Context) Result { | ||||||
|         const b = try self.buf_for_update(); |         const b = try self.buf_for_update(); | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue