diff options
author | Junegunn Choi <junegunn.c@gmail.com> | 2022-12-23 15:37:39 +0900 |
---|---|---|
committer | Junegunn Choi <junegunn.c@gmail.com> | 2022-12-23 15:37:39 +0900 |
commit | 8e283f512acb74faef6f1760927e1ef4da1b5263 (patch) | |
tree | cd98c1422932219fb35a90e02e2a9d5e7274a890 | |
parent | 73162a4bc3403e3532afa8a95008a3b4a00d554a (diff) |
Fix bind spec parser
-rw-r--r-- | src/options.go | 6 | ||||
-rw-r--r-- | src/options_test.go | 9 |
2 files changed, 14 insertions, 1 deletions
diff --git a/src/options.go b/src/options.go index 6eafa545..1fb649f2 100644 --- a/src/options.go +++ b/src/options.go @@ -938,7 +938,11 @@ Loop: break } // Keep + or , at the end - masked += strings.Repeat(" ", loc[1]-1) + action[loc[1]-1:loc[1]] + lastChar := action[loc[1]-1] + if lastChar == '+' || lastChar == ',' { + loc[1]-- + } + masked += strings.Repeat(" ", loc[1]) action = action[loc[1]:] } masked = strings.Replace(masked, "::", string([]rune{escapedColon, ':'}), -1) diff --git a/src/options_test.go b/src/options_test.go index fbf319e0..8754716c 100644 --- a/src/options_test.go +++ b/src/options_test.go @@ -499,3 +499,12 @@ func TestParseSingleActionListError(t *testing.T) { t.Errorf("Failed to detect error") } } + +func TestMaskActionContents(t *testing.T) { + original := ":execute((f)(o)(o)(b)(a)(r))+change-query@qu@ry@+up,x:reload:hello:world" + expected := ":execute +change-query +up,x:reload " + masked := maskActionContents(original) + if masked != expected { + t.Errorf("Not masked: %s", masked) + } +} |