From 7fe5a0a37e6eaf375494a246859bd4ca772a0a38 Mon Sep 17 00:00:00 2001 From: rsteube Date: Sun, 3 Dec 2023 00:31:52 +0100 Subject: [PATCH] wordbreaks: fix open quotes --- tokenslice.go | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/tokenslice.go b/tokenslice.go index 0e54857..7f0be64 100644 --- a/tokenslice.go +++ b/tokenslice.go @@ -1,6 +1,9 @@ package shlex -import "strconv" +import ( + "strconv" + "strings" +) type TokenSlice []Token @@ -103,9 +106,18 @@ func (t TokenSlice) WordbreakPrefix() string { found = true } + switch token.State { + case QUOTING_STATE, QUOTING_ESCAPING_STATE: + found = true + } + if found { prefix = token.Value + prefix } } + + if prefix == "" && len(t) > 0 { + prefix = "~" + } return prefix }