Fix jump + add jump to position

This commit is contained in:
Matúš Púll 2025-04-16 15:02:07 +02:00
parent ea7db7ef4e
commit 178bcc2cd5

View file

@ -208,16 +208,24 @@ void jump(count_type r) {
count_type last_start = file.size()-LINES; count_type last_start = file.size()-LINES;
if(last_start < 0) if(last_start < 0)
last_start = 0; last_start = 0;
file_offset = r;
if(file_offset > last_start)
file_offset = last_start;
cur.r = 0; cur.r = 0;
file_offset = r;
if(file_offset > last_start) {
file_offset = last_start;
cur.r = r - file_offset;
if(cur.r >= LINES)
cur.r = LINES-1;
}
jump_line_end(); jump_line_end();
} }
// Jump to position
void jump(position p) {
jump(p.r);
cur.c = p.c;
}
int main(int argc, char* argv[]) { int main(int argc, char* argv[]) {
// Check valid filename and load // Check valid filename and load
if(argc <= 1) if(argc <= 1)
return 1; return 1;