From 151c04db40ec11f6659660aa365fa427f41f5ca4 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 9 Sep 2026 01:53:58 +0000 Subject: [PATCH] chore(deps): bump github.com/mattn/go-runewidth from 0.0.28 to 0.0.29 Bumps [github.com/mattn/go-runewidth](https://github.com/mattn/go-runewidth) from 0.0.28 to 0.0.29. - [Commits](https://github.com/mattn/go-runewidth/compare/v0.0.28...v0.0.29) --- updated-dependencies: - dependency-name: github.com/mattn/go-runewidth dependency-version: 0.0.29 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- go.mod | 2 +- go.sum | 4 ++-- .../mattn/go-runewidth/runewidth.go | 24 ++++++++++++++----- vendor/modules.txt | 2 +- 4 files changed, 22 insertions(+), 10 deletions(-) diff --git a/go.mod b/go.mod index f8152f83..d0043fe9 100644 --- a/go.mod +++ b/go.mod @@ -11,7 +11,7 @@ require ( github.com/charmbracelet/x/term v0.2.2 github.com/dlclark/regexp2/v2 v2.7.1 github.com/jessevdk/go-flags v1.6.1 - github.com/mattn/go-runewidth v0.0.28 + github.com/mattn/go-runewidth v0.0.29 github.com/muesli/termenv v0.16.0 github.com/stretchr/testify v1.12.1 ) diff --git a/go.sum b/go.sum index a352b247..e99dc42d 100644 --- a/go.sum +++ b/go.sum @@ -40,8 +40,8 @@ github.com/mattn/go-isatty v0.0.24 h1:tGZZoVgT/KiqK1c8ocVLeDS8BSWMRd47J3Lbz7vsRe github.com/mattn/go-isatty v0.0.24/go.mod h1:nMCL3Zebbrt45jsMDgnfIwz6ydEQApk5oEI3HqDio6A= github.com/mattn/go-localereader v0.0.1 h1:ygSAOl7ZXTx4RdPYinUpg6W99U8jWvWi9Ye2JC/oIi4= github.com/mattn/go-localereader v0.0.1/go.mod h1:8fBrzywKY7BI3czFoHkuzRoWE9C+EiG4R1k4Cjx5p88= -github.com/mattn/go-runewidth v0.0.28 h1:rPyg2ybwEKPebvpzVWe1gKBkH8EQFkxO4Y0hjBeLaBU= -github.com/mattn/go-runewidth v0.0.28/go.mod h1:3qAiGCV4Koz/yuveO58qUefmUTRm8r0IGEXZ9jeHp/8= +github.com/mattn/go-runewidth v0.0.29 h1:3oGF3R/S2N9DQ3ptftzVIvg2eicmojCzlwBEmqEPDfQ= +github.com/mattn/go-runewidth v0.0.29/go.mod h1:3qAiGCV4Koz/yuveO58qUefmUTRm8r0IGEXZ9jeHp/8= github.com/muesli/ansi v0.0.0-20230316100256-276c6243b2f6 h1:ZK8zHtRHOkbHy6Mmr5D264iyp3TiX5OmNcI5cIARiQI= github.com/muesli/ansi v0.0.0-20230316100256-276c6243b2f6/go.mod h1:CJlz5H+gyd6CUWT45Oy4q24RdLyn7Md9Vj2/ldJBSIo= github.com/muesli/cancelreader v0.2.2 h1:3I4Kt4BQjOR54NavqnDogx/MIoWBFa0StPA8ELUXHmA= diff --git a/vendor/github.com/mattn/go-runewidth/runewidth.go b/vendor/github.com/mattn/go-runewidth/runewidth.go index 33168549..af03e996 100644 --- a/vendor/github.com/mattn/go-runewidth/runewidth.go +++ b/vendor/github.com/mattn/go-runewidth/runewidth.go @@ -147,7 +147,6 @@ func handleEnv() { if DefaultCondition.EastAsianWidth != EastAsianWidth { DefaultCondition.EastAsianWidth = EastAsianWidth if len(DefaultCondition.combinedLut) > 0 { - DefaultCondition.combinedLut = DefaultCondition.combinedLut[:0] CreateLUT() } } @@ -355,7 +354,12 @@ var nonprint = table{ // Condition have flag EastAsianWidth whether the current locale is CJK or not. type Condition struct { - combinedLut []byte + combinedLut []byte + // The flags combinedLut was built from, so that CreateLUT can tell a + // table that is still current from one that has to be rebuilt. + lutEastAsianWidth bool + lutStrictEmojiNeutral bool + EastAsianWidth bool StrictEmojiNeutral bool @@ -421,6 +425,11 @@ func (c *Condition) CreateLUT() { const max = 0x110000 lut := c.combinedLut if len(c.combinedLut) != 0 { + if c.lutEastAsianWidth == c.EastAsianWidth && c.lutStrictEmojiNeutral == c.StrictEmojiNeutral { + // The table still matches the flags, so rebuilding it + // would produce the same bytes. + return + } // Remove so we don't use it. c.combinedLut = nil } else { @@ -433,6 +442,8 @@ func (c *Condition) CreateLUT() { lut[i] = uint8(x0) | uint8(x1)<<4 } c.combinedLut = lut + c.lutEastAsianWidth = c.EastAsianWidth + c.lutStrictEmojiNeutral = c.StrictEmojiNeutral } // graphemeWidth returns the width of a single grapheme cluster: the sum of @@ -566,7 +577,9 @@ func (c *Condition) TruncatePrefix(s string, w int, prefix string) string { func (c *Condition) Wrap(s string, w int) string { width := 0 var out strings.Builder - out.Grow(len(s) + len(s)/w + 1) + // max keeps the capacity hint from dividing by zero when w is 0; a + // non-positive width breaks before every rune, as it always has. + out.Grow(len(s) + len(s)/max(w, 1) + 1) for _, r := range s { cw := c.RuneWidth(r) if r == '\n' { @@ -664,9 +677,8 @@ func FillRight(s string, w int) string { // CreateLUT will create an in-memory lookup table of 557055 bytes for faster operation. // This should not be called concurrently with other operations. +// If flags in DefaultCondition are changed, CreateLUT should be called again; +// a call that finds the table already current is a no-op. func CreateLUT() { - if len(DefaultCondition.combinedLut) > 0 { - return - } DefaultCondition.CreateLUT() } diff --git a/vendor/modules.txt b/vendor/modules.txt index f90a6159..18d14b83 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -61,7 +61,7 @@ github.com/mattn/go-isatty # github.com/mattn/go-localereader v0.0.1 ## explicit github.com/mattn/go-localereader -# github.com/mattn/go-runewidth v0.0.28 +# github.com/mattn/go-runewidth v0.0.29 ## explicit; go 1.23 github.com/mattn/go-runewidth # github.com/muesli/ansi v0.0.0-20230316100256-276c6243b2f6