summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/tokenizer.go4
-rw-r--r--test/test_core.rb9
2 files changed, 12 insertions, 1 deletions
diff --git a/src/tokenizer.go b/src/tokenizer.go
index 573a3576..edf36903 100644
--- a/src/tokenizer.go
+++ b/src/tokenizer.go
@@ -225,7 +225,9 @@ func StripLastDelimiter(str string, delimiter Delimiter) string {
locs := delimiter.regex.FindAllStringIndex(str, -1)
if len(locs) > 0 {
lastLoc := locs[len(locs)-1]
- str = str[:lastLoc[0]]
+ if lastLoc[1] == len(str) {
+ str = str[:lastLoc[0]]
+ }
}
}
return strings.TrimRightFunc(str, unicode.IsSpace)
diff --git a/test/test_core.rb b/test/test_core.rb
index 0e60b57e..9328dd6c 100644
--- a/test/test_core.rb
+++ b/test/test_core.rb
@@ -1773,6 +1773,15 @@ class TestCore < TestInteractive
end
end
+ def test_accept_nth_regex_delimiter_strip_last
+ tmux.send_keys %((echo "foo:,bar:,baz"; echo "foo:,bar:,baz:,qux:,") | #{FZF} --multi --delimiter='[:,]+' --accept-nth 2.. --sync --bind 'load:select-all+accept' > #{tempname}), :Enter
+ wait do
+ assert_path_exists tempname
+ # Last delimiter and the whitespaces are removed
+ assert_equal ['bar:,baz', 'bar:,baz:,qux'], File.readlines(tempname, chomp: true)
+ end
+ end
+
def test_accept_nth_template
tmux.send_keys %(echo "foo ,bar,baz" | #{FZF} -d, --accept-nth '1st: {1}, 3rd: {3}, 2nd: {2}' --sync --bind start:accept > #{tempname}), :Enter
wait do