[Bug]: Long code blocks can overlap or show garbled content when collapsed/expanded

Author: ilcpmCreated Sep 28, 2026Updated Sep 29, 2026
Labelsbugp2windowsui-ux

This issue was translated automatically.

Issue Checklist

  • I understand that issues are for feedback and problem solving, not for complaining in the comment section, and will provide as much information as possible to help solve the problem.
  • My issue is not listed in the FAQ.
  • I've looked at pinned issues and searched for existing Open Issues, Closed Issues, and Discussions, no similar issue or discussion was found.
  • I've filled in short, clear headings so that developers can quickly identify a rough idea of what to expect when flipping through the list of issues. And not "a suggestion", "stuck", etc.
  • I've confirmed that I am using the latest version of Cherry Studio.

Platform

Windows

Version

2.1.3

Bug Description

Image

As shown in the image, this was originally a folded code block. After I expanded this code block, the two lines of code on lines 38 and 39 clearly don't match the context here. After observation, these two lines appear to be duplicates of the first and second lines of code. The original lines 38 and 39 were overwritten, and you need to switch the conversation and reload the rendering to get the normal result.

Steps To Reproduce

The trigger cause and conditions are unknown, and there's no way to reliably reproduce it. Roughly, when encountering code with more than 40 lines, the code block will be partially folded by default. After double-clicking to expand the code block, this kind of problem is likely to occur. Long conversations are more prone to this.

Expected Behavior

Omitted...

Relevant Log Output

bash

Additional Context

I'm pasting the complete code here for your testing.

python
import threading, time
from collections import deque

class BoundedBuffer:                                    # 这个类就是一个管程
    def __init__(self, n):
        self.buf = deque()                              # 共享数据:外面只能通过 put/get 访问
        self.n = n
        self.lock = threading.Lock()                    # 管程的入口锁
        self.not_full = threading.Condition(self.lock)  # 条件变量:缓冲区不满
        self.not_empty = threading.Condition(self.lock) # 条件变量:缓冲区不空

    def put(self, item):
        with self.lock:                                 # 进入管程(别人在里面,就等在这一行)
            while len(self.buf) == self.n:
                self.not_full.wait()                    # 满了:暂时离开管程去等,让别人进来
            self.buf.append(item)
            print(f"生产 {item},缓冲区:{list(self.buf)}")
            self.not_empty.notify()                     # 叫醒一个在等"不空"的线程
        # 执行完 with 块 = 离开管程

    def get(self):
        with self.lock:
            while not self.buf:
                self.not_empty.wait()
            item = self.buf.popleft()
            print(f"        消费 {item},缓冲区:{list(self.buf)}")
            self.not_full.notify()
            return item

# ======== 下面是"使用者":没有一行锁,也没有 P、V ========
box = BoundedBuffer(3)

def producer():
    for i in range(10):
        box.put(i)

def consumer():
    for _ in range(10):
        box.get()
        time.sleep(0.2)                                 # 消费得慢,缓冲区会被塞满

threading.Thread(target=producer).start()
threading.Thread(target=consumer).start()

Original Content

Issue Checklist

  • I understand that issues are for feedback and problem solving, not for complaining in the comment section, and will provide as much information as possible to help solve the problem.
  • My issue is not listed in the FAQ.
  • I've looked at pinned issues and searched for existing Open Issues, Closed Issues, and Discussions, no similar issue or discussion was found.
  • I've filled in short, clear headings so that developers can quickly identify a rough idea of what to expect when flipping through the list of issues. And not "a suggestion", "stuck", etc.
  • I've confirmed that I am using the latest version of Cherry Studio.

Platform

Windows

Version

2.1.3

Bug Description

Image

如图,这是一个本来折叠起来的代码块,在我展开这个代码块之后,第38和39行的两行代码明显不符合此处的语境。经过观察,这两行代码应该是第一行和第二行代码的重复 原本的第38和39行代码被覆盖掉了,需要切换对话,重新加载渲染才能得到正常的结果

Steps To Reproduce

触发原因和条件未知,没有办法稳定地复现。大概就是遇到40行以上的代码时,代码块默认会被折叠一部分,双击展开代码块之后就容易遇到这种问题 长对话容易出现

Expected Behavior

省略……

Relevant Log Output

bash

Additional Context

我把这份代码完整地贴在这里,供你们测试

python
import threading, time
from collections import deque

class BoundedBuffer:                                    # 这个类就是一个管程
    def __init__(self, n):
        self.buf = deque()                              # 共享数据:外面只能通过 put/get 访问
        self.n = n
        self.lock = threading.Lock()                    # 管程的入口锁
        self.not_full = threading.Condition(self.lock)  # 条件变量:缓冲区不满
        self.not_empty = threading.Condition(self.lock) # 条件变量:缓冲区不空

    def put(self, item):
        with self.lock:                                 # 进入管程(别人在里面,就等在这一行)
            while len(self.buf) == self.n:
                self.not_full.wait()                    # 满了:暂时离开管程去等,让别人进来
            self.buf.append(item)
            print(f"生产 {item},缓冲区:{list(self.buf)}")
            self.not_empty.notify()                     # 叫醒一个在等"不空"的线程
        # 执行完 with 块 = 离开管程

    def get(self):
        with self.lock:
            while not self.buf:
                self.not_empty.wait()
            item = self.buf.popleft()
            print(f"        消费 {item},缓冲区:{list(self.buf)}")
            self.not_full.notify()
            return item

# ======== 下面是"使用者":没有一行锁,也没有 P、V ========
box = BoundedBuffer(3)

def producer():
    for i in range(10):
        box.put(i)

def consumer():
    for _ in range(10):
        box.get()
        time.sleep(0.2)                                 # 消费得慢,缓冲区会被塞满

threading.Thread(target=producer).start()
threading.Thread(target=consumer).start()