The normal behaviour of PRIMARY selection in linux (middle mouse button) is that it remains until a new selection is made. Some editors, like Atom, honour this behaviour. In Geany, after selecting, a left mouse click anywhere inside the editor erases the PRIMARY selection: You cannot paste it any more.
I think that keeping the PRIMARY selection is more natural: you are not forced to paste immediately after selection! Besides, because it is less natural, I frequently end pasting in the wrong place.
Oddly, if you select and middle-button paste imediately, now PRIMARY selection becomes permanent: you can left-click as many times as you want (and middle-mouse paste as many times as you want), and middle-button keeps the PRIMARY selection.
The Scintilla editing widget that Geany uses defines a selection as between the current cursor and the anchor, and clicking in the widget moves _both_ the anchor and cursor to the same place so there is no longer any selection. So its hard to see how it would work since X11 (not Unix, its just that Unix usually uses X11) has no actual clipboard to keep the selection on, its requested dynamically when the middle click happens.
This is the same as all the editors I have available to test, the one outlier is this edit here in the browser, in Chromium, which explains why atom does it since electron is Chromium. Its probable that Chromium isn't actually using the X11 paste on middle click and is doing it itself.
And the cause of your ending up pasting in the wrong place may be that middle click pastes where the X11 cursor is, not where the Scintilla cursor is. That happens even here in the browser. Of course its hard to ensure that cursor is exactly where you want it, since it can be on any pixel, and has to be mapped to the character position.
Scintilla grew up on Windows, so as an baby editor it only had copy/paste and thats still its main way of working since the paste goes to the editing widget cursor position that is stable and well defined.
Closed #2323.
Closed as the behaviour is normal X11 operation and comes from Scintilla not Geany.
github-comments@lists.geany.org