[PATCH] vi: restore 0 offset after :set noXXX command

Alison Winters alisonatwork at outlook.com
Sat Feb 27 23:18:45 UTC 2021


Fixes bug where commands after the first noXXX command are ignored.
     e.g. :set noic tabstop=4
---
  editors/vi.c | 6 ++++--
  1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/editors/vi.c b/editors/vi.c
index 458ca6293..2010cd491 100644
--- a/editors/vi.c
+++ b/editors/vi.c
@@ -2709,7 +2709,6 @@ static void colon(char *buf)
  #  if ENABLE_FEATURE_VI_SETOPTS
  		char *argp;
  #  endif
-		i = 0;			// offset into args
  		// only blank is regarded as args delimiter. What about tab '\t'?
  		if (!args[0] || strcasecmp(args, "all") == 0) {
  			// print out values of all options
@@ -2732,8 +2731,11 @@ static void colon(char *buf)
  #  if ENABLE_FEATURE_VI_SETOPTS
  		argp = args;
  		while (*argp) {
-			if (strncmp(argp, "no", 2) == 0)
+			if (strncmp(argp, "no", 2) == 0) {
  				i = 2;		// ":set noautoindent"
+			} else {
+				i = 0;
+			}
  			setops(argp, "autoindent ", i, "ai", VI_AUTOINDENT);
  			setops(argp, "flash "     , i, "fl", VI_ERR_METHOD);
  			setops(argp, "ignorecase ", i, "ic", VI_IGNORECASE);
-- 
2.30.1



More information about the busybox mailing list