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

Method insert_line

src/editor/buffer.rs:179–195  ·  view source on GitHub ↗
(&mut self, line: usize, text: &str)

Source from the content-addressed store, hash-verified

177 }
178
179 pub fn insert_line(&mut self, line: usize, text: &str) {
180 let cursor_before = self.cursor;
181 let char_idx = if line >= self.line_count() {
182 self.document.len_chars()
183 } else {
184 self.document.line_to_char(line)
185 };
186 self.document.insert_line(line, text);
187 self.cursor.clamp_to_document(&self.document);
188 let inserted = format!("{text}\n");
189 self.push_undo(UndoRecord {
190 start: char_idx,
191 inserted,
192 deleted: String::new(),
193 cursor_before,
194 });
195 }
196
197 pub fn delete_line(&mut self, line: usize) {
198 if line >= self.line_count() {

Calls 5

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