| id | 186 |
|---|---|
| title | Centralize UTF-16 column helpers in internal/mdtext |
| status | ✅ |
| summary | Lift the triplicated nonNegativeUTF16RuneLen / utf16FromByteOffset helpers out of internal/lsp, internal/rename, and cmd/mdsmith into internal/mdtext, removing the three private copies. |
| model | |
| depends-on |
Export three UTF-16 helpers from
internal/mdtext:
NonNegativeUTF16RuneLenUTF16FromByteOffsetUTF16ToByteOffset
Remove the three private copies in
internal/lsp, internal/rename, and
cmd/mdsmith.
- Add exported functions to
internal/mdtext:
NonNegativeUTF16RuneLen(r rune) intUTF16FromByteOffset(line []byte, byteOff int) intUTF16ToByteOffset(line []byte, target int) int
Add unit tests for each in
internal/mdtext/utf16_test.go.
- Replace
nonNegativeUTF16RuneLenandutf16FromByteOffsetininternal/lsp/diagnostics.gowith calls to the newmdtextfunctions. Updateinternal/lsp/server_test.goto remove its now-stale private test of the helper. - Replace
nonNegativeUTF16RuneLenandutf16FromByteOffsetininternal/rename/rename.gowith calls to the newmdtextfunctions. Remove the private copy and its test ininternal/rename/helpers_test.go. - Replace
nonNegativeUTF16RuneLenandutf16ToByteOffsetincmd/mdsmith/rename.gowith calls tomdtext.NonNegativeUTF16RuneLenandmdtext.UTF16ToByteOffset. Updaterename_unit_test.goto remove the now-stale private test. - Run
go build ./...andgo test ./...to confirm no breakage. - Run
go tool golangci-lint runto confirm no lint regressions.
-
internal/mdtextexportsNonNegativeUTF16RuneLen,UTF16FromByteOffset, andUTF16ToByteOffset, each with a dedicated unit test. - No private copy of
nonNegativeUTF16RuneLen,utf16FromByteOffset, orutf16ToByteOffsetremains ininternal/lsp/,internal/rename/, orcmd/mdsmith/. - All tests pass:
go test ./... -
go tool golangci-lint runreports no issues.