esc

Externally Scriptable Editor

git clone git://mccd.space/esc

commit c0252e0f59224e18a2fcaf280f75e080ab4d7e3a
parent d0fcbcda3d81161dc288ca099fdaeca8b88f686b
Author: Marc Coquand <marc@coquand.email>
Date:   Wed, 25 Feb 2026 16:25:59 +0100

Paste should highlight what has been added

Diffstat:
Mmain.c | 5+++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/main.c b/main.c
@@ -233,15 +233,17 @@ void handle_events(Editor *ed, SDL_Renderer *renderer, float *scroll_x,
 							free(selection);
 						}
 					} else {
-						/* paste from primary selection
+						/* Paste
 						 */
 						if (SDL_HasPrimarySelectionText()) {
 							char *text =
 							    SDL_GetPrimarySelectionText();
 							if (text) {
+    								int start = ed->cursor_idx;
 								editor_insert_text(
 								    ed, text,
 								    false);
+								ed->selection_anchor = start;
 							}
 							SDL_free(text);
 						}
@@ -273,7 +275,6 @@ void handle_events(Editor *ed, SDL_Renderer *renderer, float *scroll_x,
 			}
 		} while (SDL_PollEvent(&event));
 
-		/* Auto-sync primary selection for Wayland */
 		if (editor_has_selection(ed)) {
 			char *sel = editor_get_selection(ed);
 			if (sel) {