Skip to content

Commit b4e2de5

Browse files
committed
fix: Prevent IME tooltips from being deleted by parent window cleanup
1 parent 7ee1a06 commit b4e2de5

File tree

4 files changed

+13
-4
lines changed

4 files changed

+13
-4
lines changed

editor/imetooltip.go

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,15 @@ func (i *IMETooltip) show() {
147147
return
148148
}
149149

150+
i.Show()
151+
i.isShown = true
152+
}
153+
154+
func (i *IMETooltip) setGrid() {
155+
if i.s == nil || i.s.ws == nil {
156+
return
157+
}
158+
150159
if !(i.s.ws.palette != nil && i.s.ws.palette.widget != nil && i.s.ws.palette.widget.IsVisible()) {
151160
win, ok := i.s.getWindow(i.s.ws.cursor.gridid)
152161
if !ok || win == nil {
@@ -163,9 +172,7 @@ func (i *IMETooltip) show() {
163172
i.setFont(i.s.font)
164173
}
165174

166-
i.Show()
167175
i.Raise()
168-
i.isShown = true
169176
}
170177

171178
func (i *IMETooltip) updateVirtualCursorPos() {

editor/screen.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1062,6 +1062,7 @@ func (s *Screen) gridCursorGoto(args []interface{}) {
10621062
}
10631063

10641064
win.raise()
1065+
win.s.tooltip.setGrid()
10651066

10661067
// reset smooth scroll scrolling offset
10671068
win.scrollPixels2 = 0
@@ -1508,7 +1509,7 @@ func (s *Screen) update() {
15081509
s.windows.Range(func(grid, winITF interface{}) bool {
15091510
win := winITF.(*Window)
15101511
// if grid is dirty, we remove this grid
1511-
if win.isGridDirty {
1512+
if win.isGridDirty && !win.isSameAsCursorGrid() {
15121513
// if win.queueRedrawArea[2] > 0 || win.queueRedrawArea[3] > 0 {
15131514
// // If grid has an update area even though it has a dirty flag,
15141515
// // it will still not be removed as a valid grid

editor/window.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1169,7 +1169,7 @@ func (w *Window) applyTemporaryMousescroll(ms string) {
11691169
}
11701170
}
11711171

1172-
func (w *Window) isEventEmitOnCursorGrid() bool {
1172+
func (w *Window) isSameAsCursorGrid() bool {
11731173
return w.grid == w.s.ws.cursor.gridid
11741174
}
11751175

editor/workspace.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2462,6 +2462,7 @@ func (ws *Workspace) InputMethodEvent(event *gui.QInputMethodEvent) {
24622462
ws.screen.tooltip.hide()
24632463
ws.screen.refresh()
24642464
} else {
2465+
ws.screen.tooltip.setGrid()
24652466
ws.screen.tooltip.show()
24662467
ws.screen.tooltip.parsePreeditString(preeditString)
24672468
ws.screen.tooltip.update()

0 commit comments

Comments
 (0)