diff options
| author | Lukasz Kasprzak <lukas@labunix.xyz> | 2026-09-15 00:30:59 +0200 |
|---|---|---|
| committer | Lukasz Kasprzak <lukas@labunix.xyz> | 2026-09-15 00:30:59 +0200 |
| commit | 2f4e6dd8dfc7e18064e087c65ff9d28b4833cce2 (patch) | |
| tree | 7ebcbec83f0f6ee41d8541bfbcff18eba7af10fa /internal/norm/norm.go | |
| parent | 17e933a16ff7de1b06d62504e78c40e615c8b553 (diff) | |
| download | krino-2f4e6dd8dfc7e18064e087c65ff9d28b4833cce2.tar.gz krino-2f4e6dd8dfc7e18064e087c65ff9d28b4833cce2.zip | |
captures keep the combining marks of a decomposed name; test sources escape invisible characters
Diffstat (limited to 'internal/norm/norm.go')
| -rw-r--r-- | internal/norm/norm.go | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/internal/norm/norm.go b/internal/norm/norm.go index bff2127..1c2f61d 100644 --- a/internal/norm/norm.go +++ b/internal/norm/norm.go @@ -123,7 +123,9 @@ func FoldMapped(s string) Folded { } // Source returns the original text that Text[a:b] was folded from, widened -// to whole characters; without a map, Text[a:b] itself. +// to whole characters and to the characters right after them that fold to +// nothing - the combining marks of a decomposed name, which belong to the +// letter before them (plan 11 review L5); without a map, Text[a:b] itself. func (f Folded) Source(a, b int) string { switch { case f.same || f.start == nil: @@ -131,7 +133,15 @@ func (f Folded) Source(a, b int) string { case a >= b: return "" } - return f.src[f.start[a]:f.end[b-1]] + end := f.end[b-1] + for end < len(f.src) { + r, w := utf8.DecodeRuneInString(f.src[end:]) + if r == utf8.RuneError && w == 1 || Fold(f.src[end:end+w]) != "" { + break + } + end += w + } + return f.src[f.start[a]:end] } // Text puts s into the form content and keywords are compared in: Fold if |
