git: 8f10d31b4cfa - main - editors/nvi2: Fix "move forward paragraphs" (}) with numeric prefix
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Tue, 29 Aug 2023 22:45:39 UTC
The branch main has been updated by leres: URL: https://cgit.FreeBSD.org/ports/commit/?id=8f10d31b4cfaf46496a805b0b13d8b2ea209289b commit 8f10d31b4cfaf46496a805b0b13d8b2ea209289b Author: Craig Leres <leres@FreeBSD.org> AuthorDate: 2023-08-29 22:45:01 +0000 Commit: Craig Leres <leres@FreeBSD.org> CommitDate: 2023-08-29 22:45:01 +0000 editors/nvi2: Fix "move forward paragraphs" (}) with numeric prefix Two github issues identified the same problem: https://github.com/lichray/nvi2/issues/118 https://github.com/lichray/nvi2/pull/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 --- editors/nvi2/Makefile | 2 +- editors/nvi2/files/patch-vi_v__paragraph.c | 45 ++++++++++++++++++++++++++++++ 2 files changed, 46 insertions(+), 1 deletion(-) diff --git a/editors/nvi2/Makefile b/editors/nvi2/Makefile index dfa27945a477..9240ea4f4994 100644 --- a/editors/nvi2/Makefile +++ b/editors/nvi2/Makefile @@ -1,7 +1,7 @@ PORTNAME= nvi2 PORTVERSION= 2.2.0 DISTVERSIONPREFIX= v -PORTREVISION= 1 +PORTREVISION= 2 CATEGORIES= editors MAINTAINER= leres@FreeBSD.org diff --git a/editors/nvi2/files/patch-vi_v__paragraph.c b/editors/nvi2/files/patch-vi_v__paragraph.c new file mode 100644 index 000000000000..caa061cb8dfb --- /dev/null +++ b/editors/nvi2/files/patch-vi_v__paragraph.c @@ -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; \ ++ } \ + } + + /*