esc

Externally Scriptable Editor

git clone git://mccd.space/esc

commit d1ac9b1910dfccde157768ea3003e83507189ffe
parent 67e1766ec16f4b4d5e90df070aabb528cfcb97b7
Author: Marc Coquand <marc@coquand.email>
Date:   Thu, 26 Feb 2026 16:16:11 +0100

*

Diffstat:
Meditor.c | 13+++++++++++--
1 file changed, 11 insertions(+), 2 deletions(-)
diff --git a/editor.c b/editor.c
@@ -596,8 +596,17 @@ void editor_expand_selection(Editor *ed, int level) {
 	             ? ed->selection_anchor : ed->cursor_idx;
 
 	if (level == 1) {
-		/* Sentence: backward to start of line */
-		lo = find_sol(data, lo);
+		/* Backward to paragraph start */
+		{
+			int p = find_sol(data, lo);
+			while (p > 0) {
+				int prev_start = find_sol(data, p - 1);
+				if (line_is_blank(data, len, prev_start))
+					break;
+				p = prev_start;
+			}
+			lo = p;
+		}
 		/* Forward: to [.?!] + space/\n, or paragraph boundary */
 		bool found = false;
 		for (int p = hi; p < len; p++) {