<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[关于#var命令的bug提交]]></title><description><![CDATA[<p dir="auto">现象：<br />
1.如果变量的值带ANSI颜色代码，会无法打印。<br />
2.如果变量的键是数字类型，会无法正常打印。<br />
修改方案：<br />
<img src="/assets/uploads/files/1786147194932-9cd7fe56-2692-4469-9187-cb97c5647650-image.jpeg" alt="9cd7fe56-2692-4469-9187-cb97c5647650-image.jpeg" class=" img-fluid img-markdown" width="702" height="698" /><br />
"""返回字符串的显示宽度，而不是字符数量</p>
<pre><code>    注意: 字符串中若含有 ANSI 颜色等控制字符，wcswidth 会返回 -1，
    导致 len() 抛出 ValueError。此处先剥离 ANSI 转义序列再计算宽度，
    并对仍返回 -1 的情况兜底为 0。
    """
    from .session import Session
    clean = Session.PLAIN_TEXT_REGX.sub("", self.__str__())
    w = wcswidth(clean)
    return w if w &gt;= 0 else 0
</code></pre>
<p dir="auto"><img src="/assets/uploads/files/1786147288586-95e7f3d0-79c1-4f02-8eed-8a23482548f6-image.jpeg" alt="95e7f3d0-79c1-4f02-8eed-8a23482548f6-image.jpeg" class=" img-fluid img-markdown" width="754" height="106" /><br />
def getMaxLength(self, iter: Iterable):<br />
return wcswidth(str(sorted(iter, key=lambda s: wcswidth(str(s)), reverse=True)[0]))</p>
]]></description><link>https://bbs.pymud.cn/topic/38/关于-var命令的bug提交</link><generator>RSS for Node</generator><lastBuildDate>Wed, 14 Oct 2026 06:14:41 GMT</lastBuildDate><atom:link href="https://bbs.pymud.cn/topic/38.rss" rel="self" type="application/rss+xml"/><pubDate>Sat, 08 Aug 2026 00:02:09 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to 关于#var命令的bug提交 on Sun, 09 Aug 2026 08:03:26 GMT]]></title><description><![CDATA[<p dir="auto">已按你提供的见习修复上述问题，并发布0.22.8版。</p>
]]></description><link>https://bbs.pymud.cn/post/129</link><guid isPermaLink="true">https://bbs.pymud.cn/post/129</guid><dc:creator><![CDATA[newstart]]></dc:creator><pubDate>Sun, 09 Aug 2026 08:03:26 GMT</pubDate></item></channel></rss>