Skip to content

Add asynchronous clipboard selection - #6

Closed
frankischilling wants to merge 1 commit into
zyedidia:masterfrom
frankischilling:feature/async-clipboard-detection
Closed

frankischilling wants to merge 1 commit into
zyedidia:masterfrom
frankischilling:feature/async-clipboard-detection

Conversation

@frankischilling

Copy link
Copy Markdown

Applications that call GetClipboard during startup wait for command searches and backend probes. This can delay micro's interface in WSL when PATH contains many Windows directories, as reported in micro-editor/micro#4209.

GetClipboardAsync starts the existing detection sequence in a background worker and returns a Clipboard immediately. Its Init, ReadAll, and WriteAll methods wait for detection and return its errors if no backend works. Repeated Init calls share the result. Candidate order stays unchanged, and the constructor copies the candidate slice before starting the worker.

This keeps detection synchronization in clipper, as requested in the review of micro-editor/micro#4215. It does not reduce the cost of backend probes: the first clipboard operation can still wait. Callers that need an in-memory fallback can include Internal among their candidates.

Tests cover delayed initialization, first reads and writes, candidate order, slice reuse, detection errors, register forwarding, and concurrent waiters. The README documents the API and its limits.

Validation

  • Tests pass on Windows and natively in Ubuntu WSL.
  • Windows and Linux race tests pass for 20 repetitions. Linux vet passes.
  • A local micro integration passes its full Windows suite and a terminal startup/paste test in WSL.
  • Windows vet reports an existing unsafe-pointer warning in winapi.go:90, also reproduced in unchanged v0.1.1. The remaining vet checks pass with that analyzer disabled.

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.

1 participant