MCPcopy Index your code
hub / github.com/endbasic/endbasic / move_down

Method move_down

repl/src/editor.rs:249–258  ·  view source on GitHub ↗

Moves the cursor down by the given number of lines in `nlines` or to the last line if there are insufficient lines to perform the move.

(&mut self, nlines: usize)

Source from the content-addressed store, hash-verified

247 /// Moves the cursor down by the given number of lines in `nlines` or to the last line if there
248 /// are insufficient lines to perform the move.
249 fn move_down(&mut self, nlines: usize) {
250 if self.file_pos.line + nlines < self.content.len() {
251 self.file_pos.line += nlines;
252 } else {
253 self.file_pos.line = self.content.len() - 1;
254 }
255
256 let line = &self.content[self.file_pos.line];
257 self.file_pos.col = cmp::min(self.insert_col, line.len());
258 }
259
260 /// Moves the cursor up by the given number of lines in `nlines` or to the first line if there
261 /// are insufficient lines to perform the move.

Callers 1

edit_interactivelyMethod · 0.80

Calls 1

lenMethod · 0.45

Tested by

no test coverage detected