[GH-ISSUE #754] Using unicode in tview.List item cause rendering bug on Windows Terminal and VSCode Terminal #552

Closed
opened 2026-03-04 01:05:56 +03:00 by kerem · 3 comments
Owner

Originally created by @Chronyaa on GitHub (Aug 8, 2022).
Original GitHub issue: https://github.com/rivo/tview/issues/754

I try to use unicode text (here is japanese) in tview.List with list.AddItem(text, "", 0, func(){}), but when I scroll up or down list, some unwanted character is also rendered.

Here is the code:

package main

import (
	"github.com/rivo/tview"
)

func main() {
	app := tview.NewApplication()
	list := tview.NewList()
	list.ShowSecondaryText(false)
	for i := 0; i < 20; i++ {
		list.AddItem("abcdefghijklmnあ                                    ", "", 0, func() {})
		list.AddItem("abcdefghあい                                        ", "", 0, func() {})
		list.AddItem("abcdefghijあいう                                     ", "", 0, func() {})
		list.AddItem("abcdeあいうえ                                         ", "", 0, func() {})
		list.AddItem("abcdefghiあいうえお                                    ", "", 0, func() {})
	}

	app.SetRoot(list, true).Run()
}

And result in Windows Terminal, it works well before I scroll down to the end, and scroll up:
tview

VSCode Terminal:
tview_vscode

It seems this bug will trigger if:

  1. Text begins with english characters.
  2. Different line has different length leading english characters.
  3. There is some space characters at the tail of text.
Originally created by @Chronyaa on GitHub (Aug 8, 2022). Original GitHub issue: https://github.com/rivo/tview/issues/754 I try to use unicode text (here is japanese) in `tview.List` with `list.AddItem(text, "", 0, func(){})`, but when I scroll up or down list, some unwanted character is also rendered. Here is the code: ```golang package main import ( "github.com/rivo/tview" ) func main() { app := tview.NewApplication() list := tview.NewList() list.ShowSecondaryText(false) for i := 0; i < 20; i++ { list.AddItem("abcdefghijklmnあ      ", "", 0, func() {}) list.AddItem("abcdefghあい     ", "", 0, func() {}) list.AddItem("abcdefghijあいう    ", "", 0, func() {}) list.AddItem("abcdeあいうえ   ", "", 0, func() {}) list.AddItem("abcdefghiあいうえお ", "", 0, func() {}) } app.SetRoot(list, true).Run() } ``` And result in Windows Terminal, it works well before I scroll down to the end, and scroll up: ![tview](https://user-images.githubusercontent.com/69758044/183455374-02c89738-e1c5-4bca-b6d2-8e4f35891cd5.png) VSCode Terminal: ![tview_vscode](https://user-images.githubusercontent.com/69758044/183456228-1273127a-dfb2-4de0-9bfe-990bec876b6f.png) It seems this bug will trigger if: 1. Text begins with english characters. 2. Different line has different length leading english characters. 3. There is some space characters at the tail of text.
kerem closed this issue 2026-03-04 01:05:57 +03:00
Author
Owner

@Chronyaa commented on GitHub (Aug 8, 2022):

It can fix by call app.Sync after each input events, so it might be the sync problem?

package main

import (
	"github.com/rivo/tview"
)

func main() {
	app := tview.NewApplication()
	list := tview.NewList()
	list.ShowSecondaryText(false)
	for i := 0; i < 20; i++ {
		list.AddItem("abcdefghijklmnあ                                    ", "", 0, func() {})
		list.AddItem("abcdefghあい                                        ", "", 0, func() {})
		list.AddItem("abcdefghijあいう                                     ", "", 0, func() {})
		list.AddItem("abcdeあいうえ                                         ", "", 0, func() {})
		list.AddItem("abcdefghiあいうえお                                    ", "", 0, func() {})
	}
	// call app.Sync after each input event
	list.SetInputCapture(func(event *tcell.EventKey) *tcell.EventKey {
		app.Sync()
		return event
	})
	app.SetRoot(list, true).Run()
}
<!-- gh-comment-id:1208315603 --> @Chronyaa commented on GitHub (Aug 8, 2022): It can fix by call `app.Sync` after each input events, so it might be the sync problem? ```golang package main import ( "github.com/rivo/tview" ) func main() { app := tview.NewApplication() list := tview.NewList() list.ShowSecondaryText(false) for i := 0; i < 20; i++ { list.AddItem("abcdefghijklmnあ      ", "", 0, func() {}) list.AddItem("abcdefghあい     ", "", 0, func() {}) list.AddItem("abcdefghijあいう    ", "", 0, func() {}) list.AddItem("abcdeあいうえ   ", "", 0, func() {}) list.AddItem("abcdefghiあいうえお ", "", 0, func() {}) } // call app.Sync after each input event list.SetInputCapture(func(event *tcell.EventKey) *tcell.EventKey { app.Sync() return event }) app.SetRoot(list, true).Run() } ```
Author
Owner

@rivo commented on GitHub (Sep 18, 2022):

I just tried it in iTerm2 on macOS and didn't get these artefacts with the latest tview version. Can you please try the latest version and let me know if you're still seeing this?

<!-- gh-comment-id:1250347354 --> @rivo commented on GitHub (Sep 18, 2022): I just tried it in iTerm2 on macOS and didn't get these artefacts with the latest `tview` version. Can you please try the latest version and let me know if you're still seeing this?
Author
Owner

@rivo commented on GitHub (Nov 13, 2022):

Please reopen / reference this issue if it is still relevant.

<!-- gh-comment-id:1312783003 --> @rivo commented on GitHub (Nov 13, 2022): Please reopen / reference this issue if it is still relevant.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/tview#552
No description provided.