Skip to content

Commit

Permalink
wordbreaks: fix open quotes
Browse files Browse the repository at this point in the history
  • Loading branch information
rsteube committed Dec 2, 2023
1 parent 0bd041d commit 7fe5a0a
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion tokenslice.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
package shlex

import "strconv"
import (
"strconv"
"strings"

Check failure on line 5 in tokenslice.go

View workflow job for this annotation

GitHub Actions / build

"strings" imported and not used

Check failure on line 5 in tokenslice.go

View workflow job for this annotation

GitHub Actions / build

"strings" imported and not used
)

type TokenSlice []Token

Expand Down Expand Up @@ -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
}

0 comments on commit 7fe5a0a

Please sign in to comment.