MCPcopy Create free account
hub / github.com/Eeive/Evcode-ide / delete_line

Method delete_line

src/editor/buffer.rs:197–221  ·  view source on GitHub ↗
(&mut self, line: usize)

Source from the content-addressed store, hash-verified

195 }
196
197 pub fn delete_line(&mut self, line: usize) {
198 if line >= self.line_count() {
199 return;
200 }
201 let cursor_before = self.cursor;
202 let start = self.document.line_to_char(line);
203 let end = if line + 1 < self.line_count() {
204 self.document.line_to_char(line + 1)
205 } else {
206 self.document.len_chars()
207 };
208 let deleted = self.document.slice_text(start, end);
209 self.document.delete_line(line);
210 self.cursor.clamp_to_document(&self.document);
211 self.selection_anchor = None;
212
213 if !deleted.is_empty() {
214 self.push_undo(UndoRecord {
215 start,
216 inserted: String::new(),
217 deleted,
218 cursor_before,
219 });
220 }
221 }
222
223 pub fn delete_char_forward(&mut self) {
224 if self.delete_selection() {

Calls 7

line_to_charMethod · 0.80
len_charsMethod · 0.80
slice_textMethod · 0.80
clamp_to_documentMethod · 0.80
is_emptyMethod · 0.80
push_undoMethod · 0.80
line_countMethod · 0.45