Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
editors/nvi2: Fix "move forward paragraphs" (}) with numeric prefix
Two github issues identified the same problem: lichray/nvi2#118 lichray/nvi2#119 For example typing "}" three times on this sample text: .PP 1 .PP 2 .PP 3 .PP 4 .PP 5 .PP 6 moves the cursor 3 paragraphs but typing "3}" (correct) moves the cursor 5 paragraphs ((2 * N) - 1, incorrect). Reported by: Walter Alejandro Iglesias, Zhihao Yuan
- Loading branch information
Craig Leres
authored and
Craig Leres
committed
Aug 29, 2023
1 parent
a2f4407
commit 8f10d31
Showing
2 changed files
with
46 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
From 517d821de7939f74a74bb6a553df0fff425fdead Mon Sep 17 00:00:00 2001 | ||
From: Zhihao Yuan <lichray@gmail.com> | ||
Date: Tue, 29 Aug 2023 03:50:08 -0500 | ||
Subject: [PATCH] Treat consecutive paragraph indicators as different | ||
paragraphs (#119) | ||
|
||
Consecutive empty lines count toward the same state, so there're | ||
2x states (to get in and out). ^L and .PP are counted as text, | ||
hitting those in the text should be treated as getting out of a | ||
paragraph and then getting in. | ||
|
||
Closes: #118 | ||
See also: https://marc.info/?l=openbsd-bugs&m=169100763926909&w=2 | ||
--- | ||
vi/v_paragraph.c | 11 ++++++++--- | ||
1 file changed, 8 insertions(+), 3 deletions(-) | ||
|
||
diff --git a/vi/v_paragraph.c b/vi/v_paragraph.c | ||
index abe8d9cf..2d7f0756 100644 | ||
--- vi/v_paragraph.c.orig 2020-08-01 22:27:51 UTC | ||
+++ vi/v_paragraph.c | ||
@@ -39,15 +39,20 @@ | ||
if (p[0] == '\014') { \ | ||
if (!--cnt) \ | ||
goto found; \ | ||
+ if (pstate == P_INTEXT && !--cnt) \ | ||
+ goto found; \ | ||
continue; \ | ||
} \ | ||
if (p[0] != '.' || len < 2) \ | ||
continue; \ | ||
for (lp = VIP(sp)->ps; *lp != '\0'; lp += 2) \ | ||
if (lp[0] == p[1] && \ | ||
- (lp[1] == ' ' && len == 2 || lp[1] == p[2]) && \ | ||
- !--cnt) \ | ||
- goto found; \ | ||
+ (lp[1] == ' ' && len == 2 || lp[1] == p[2])) { \ | ||
+ if (!--cnt) \ | ||
+ goto found; \ | ||
+ if (pstate == P_INTEXT && !--cnt) \ | ||
+ goto found; \ | ||
+ } \ | ||
} | ||
|
||
/* |