diff options
-rw-r--r-- | editors/vi.c | 27 |
1 files changed, 15 insertions, 12 deletions
diff --git a/editors/vi.c b/editors/vi.c index f71897253..d37357edd 100644 --- a/editors/vi.c +++ b/editors/vi.c | |||
@@ -3636,21 +3636,24 @@ static void do_cmd(int c) | |||
3636 | break; | 3636 | break; |
3637 | case '{': // {- move backward paragraph | 3637 | case '{': // {- move backward paragraph |
3638 | case '}': // }- move forward paragraph | 3638 | case '}': // }- move forward paragraph |
3639 | dir = c == '}' ? FORWARD : BACK; | ||
3639 | do { | 3640 | do { |
3640 | dir = c == '}' ? FORWARD : BACK; | 3641 | int skip = TRUE; // initially skip consecutive empty lines |
3641 | // skip over consecutive empty lines | 3642 | while (dir == FORWARD ? dot < end - 1 : dot > text) { |
3642 | while ((dir == FORWARD ? dot < end - 1 : dot > text) && | 3643 | if (*dot == '\n' && dot[dir] == '\n') { |
3643 | *dot == '\n' && dot[dir] == '\n') { | 3644 | if (!skip) { |
3645 | if (dir == FORWARD) | ||
3646 | ++dot; // move to next blank line | ||
3647 | goto dc2; | ||
3648 | } | ||
3649 | } | ||
3650 | else { | ||
3651 | skip = FALSE; | ||
3652 | } | ||
3644 | dot += dir; | 3653 | dot += dir; |
3645 | } | 3654 | } |
3646 | q = char_search(dot, "\n\n", ((unsigned)dir << 1) | FULL); | 3655 | goto dc6; // end of file |
3647 | if (q != NULL) { // found blank line | 3656 | dc2: continue; |
3648 | dot = next_line(q); // move to next blank line | ||
3649 | } | ||
3650 | else { // blank line not found, move to end of file | ||
3651 | dot = dir == FORWARD ? end - 1 : text; | ||
3652 | break; | ||
3653 | } | ||
3654 | } while (--cmdcnt > 0); | 3657 | } while (--cmdcnt > 0); |
3655 | break; | 3658 | break; |
3656 | #endif /* FEATURE_VI_SEARCH */ | 3659 | #endif /* FEATURE_VI_SEARCH */ |