Skip to content

fix(display): prevent decoration redraw flicker during external clipboard synchronization - #4258

Open
AdamMagued wants to merge 1 commit into
micro-editor:masterfrom
AdamMagued:fix-issue-4248
Open

AdamMagued wants to merge 1 commit into
micro-editor:masterfrom
AdamMagued:fix-issue-4248

Conversation

@AdamMagued

Copy link
Copy Markdown

Fixes #4248

Summary of Changes

  1. Buffer Window Rendering State Tracking and Gating:

    • Introduced RenderState in internal/display/bufwindow.go capturing window geometry, viewport scroll coordinates, buffer modification status, cursor/selection bounds, and decoration states (active flag, dividers, scrollbar position, statusline string).
    • Added GetRenderState(), ShouldRedraw(), NeedsRedraw(), Invalidate(), LastRenderState(), and SetRedrawDebounce() to BufWindow.
    • Gated redundant redrawing in BufWindow.Display() when visual state has not changed or when events occur without buffer modifications.
  2. External Clipboard Synchronization Gating and Debouncing:

    • Added duplicate write gating in internal/clipboard/clipboard.go (LastWritten cache) to prevent re-invoking external clipboard tools (such as wl-copy) when register contents are unchanged.
    • Added write debouncing support via SetWriteDebounce() and cache invalidation via ResetCache().
    • Added RedrawDebounced() in internal/screen/screen.go to coalesce rapid consecutive redraw triggers.
  3. StatusLine Text Inspection:

    • Extracted FormatText() and StatusString() on StatusLine in internal/display/statusline.go to provide deterministic statusline string inspection for render state comparison.
  4. Documentation:

    • Added Wayland and wl-clipboard documentation to runtime/help/copypaste.md detailing popup surface behavior under compositors without wlr-data-control, along with mitigation settings (clipboard terminal, useprimary false).
  5. Automated Unit Testing:

    • Added internal/display/bufwindow_test.go verifying buffer window rendering state initialization, change detection, display gating, buffer edit tracking, external clipboard synchronization without buffer edits, and decoration change responses.
    • Added internal/clipboard/clipboard_test.go verifying duplicate write gating, debouncing, cache resets, and register tracking.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Window decoration flickering when clipboard is external

1 participant