<ctrl>c does not copy the selection (the selection popover Copy button works)
Describe the bug
Pressing <ctrl>c with text selected does not copy anything — the clipboard is left
untouched. Clicking Copy in the selection popover works, and <ctrl>f (Selection
Search) works even though it is provided by the same action group. So the accelerator
and the action group are fine; the failure is specific to the copy action.
To Reproduce
- Open any EPUB
- Select some text — the selection popover appears
- Press
<ctrl>c(tested with the popover still open, and after it had closed — both fail) - Paste into another application, or run
wl-pastein a terminal - Nothing is pasted:
wl-pasteprints the previous clipboard contents, or "Nothing is copied" if the clipboard was empty
Replacing step 3 with a click on the popover's Copy button copies the text correctly.
Expected behavior
<ctrl>c should copy the selection. It is a documented shortcut — the help overlay lists
it (src/ui/help-overlay.ui:168, "With Selection → Selection Copy <ctrl>c").
Version:
- Foliate version: 3.3.0 (latest release)
- OS/Distribution and version: Arch Linux (rolling, 2026-09); GTK 4.22.5, webkitgtk-6.0 2.52.6, gjs 1.88.1
- Desktop environment: niri (Wayland)
- Installation method: pacman
Additional context
Localisation from the 3.3.0 source. Nothing is printed to the WebKit inspector console when this happens — the copy simply does not happen.
src/book-viewer.js:760 maps the key to the action, and src/book-viewer.js:891 is the
only place a selection action group is inserted — on the SelectionPopover:
// src/book-viewer.js:760
'<ctrl>c': 'selection.copy',
// src/book-viewer.js:891
popover.insert_action_group('selection', utils.addSimpleActions({
'copy': () => resolve('copy'), // :892
...
'search': () => { // :909
this._search_entry.text = content
this._search_bar.search_mode_enabled = true
this._flap.show_sidebar = true
this._search_view.doSearch()
},search carries out its whole effect inside the GTK closure and never looks at the resolved
value. copy only calls resolve('copy') — everything else happens back in the web process:
// src/reader/reader.js:412
case 'copy': getHTML(range).then(html =>
emit({ type: 'selection', action, text, html }))So when the value that comes back is not 'copy', no branch matches and nothing happens,
silently. That is consistent with what is observed (no error anywhere).
The same promise has a fallback that resolves it with undefined:
// src/book-viewer.js:922-924
// it seems `closed` is emitted before the actions are run
// so it needs the timeout
'closed': () => setTimeout(() => resolved ? null : resolve(), 0),resolved is only ever set by the highlight action, so for copy this fallback always
calls resolve() with no argument. If the popover's closed handler wins the race against
the action's activation, the web side receives undefined and the switch falls through.
That would also explain the click/shortcut asymmetry: a click activates the action synchronously, whereas the keyboard accelerator appears to lose the race.
Suggested fix: make copy not depend on the resolved value (e.g. let the action do the work
the way search does), or make the closed fallback incapable of winning the race.
Confidence note: the observations (<ctrl>c never copies, <ctrl>f does, the popover
button does, no console error) are measured. The race direction in the last paragraph is
inferred from reading the code — I could not instrument it.
Source: johnfactotum/foliate