Browse code

Implement relative go-to-line (i.e. ctrl+q-l '+5')

Dario Rodriguez authored on 04/12/2021 18:04:41
Showing 1 changed files
... ...
@@ -1287,7 +1287,12 @@ re_processcommand(re_t *re)
1287 1287
         } else if(strcmp(re->command,COMMAND_GOTOLINE)==0) {
1288 1288
                 int line;
1289 1289
                 long pos;
1290
-                line=atoi(re->commandbuf)-1;
1290
+                if(re->commandbuf[0]=='+')
1291
+                        line=re->curline+atoi(re->commandbuf+1);
1292
+                else if(re->commandbuf[0]=='-')
1293
+                        line=re->curline-atoi(re->commandbuf+1);
1294
+                else
1295
+                        line=atoi(re->commandbuf)-1;
1291 1296
                 line=(line<0)?0:line;
1292 1297
                 if(redata_linecol2pos(re->data,line,re->curcol,&pos,NULL)==-1) {
1293 1298
                         re->command=COMMAND_WARNING;