← Commit list

8b571bd7b

Ron Yorston
Ron Yorston
2021-03-29
SUCCESS Duration: 152s

Subject

vi: improve motion by paragraph

Binary

No binary (build failed)

Architecture & Compiler Flags

Architecture: x86_64-linux-gnu Compiler: gcc (Ubuntu 11.4.0-1ubuntu1~22.04.3) 11.4.0

—

Build Log

(log yok)

Commit Diff GitHub →

editors/vi.c+11 -3
@@ -3515,12 +3515,20 @@ static void do_cmd(int c)
case '{': // {- move backward paragraph
case '}': // }- move forward paragraph
do {
- q = char_search(dot, "\n\n", c == '{' ?
- ((unsigned)BACK << 1) | FULL :
- (FORWARD << 1) | FULL);
+ dir = c == '}' ? FORWARD : BACK;
+ // skip over consecutive empty lines
+ while ((dir == FORWARD ? dot < end - 1 : dot > text) &&
+ *dot == '\n' && dot[dir] == '\n') {
+ dot += dir;
+ }
+ q = char_search(dot, "\n\n", ((unsigned)dir << 1) | FULL);
if (q != NULL) { // found blank line
dot = next_line(q); // move to next blank line
}
+ else { // blank line not found, move to end of file
+ dot = dir == FORWARD ? end - 1 : text;
+ break;
+ }
} while (--cmdcnt > 0);
break;
#endif /* FEATURE_VI_SEARCH */