[Github-comments] [geany] Hang on "Reflow" with lots of spaces (#848)

Colomban Wendling notifications at xxxxx
Mon Jan 4 16:38:44 UTC 2016


OK, the actual problem seem to be that as is the autoindent triggered by newline (expected) will autoindent wider than the original (line start) one, and start messing up everything.

```diff
diff --git a/src/keybindings.c b/src/keybindings.c
index 8913c57..4da0dba 100644
--- a/src/keybindings.c
+++ b/src/keybindings.c
@@ -2247,6 +2249,11 @@ static gint split_line(GeanyEditor *editor, gint column)
                if (!found)
                        break;
 
+               /* don't split on trailing spaces, which would mess up with auto-indent
+                * and possibly lead to infinite loop */
+               while (pos + 1 < lend && sci_get_char_at(sci, pos + 1) == GDK_space)
+                       pos ++;
+
                sci_set_current_position(sci, pos + 1, FALSE);
                sci_cancel(sci); /* don't select from completion list */
                sci_send_command(sci, SCI_NEWLINE);
```

Fixes the lock and some unexpected behavior, but the behavior is probably not great as it'll split very early because of all the spaces.  Maybe we'd like to trim repeated spaces, but that might also be unwanted… not sure.  What do you think?

Also the reflow code has weird behavior regarding tabs, maybe we should also allow splitting on tabs (or even `g_ascii_isspace()`)?

---
Reply to this email directly or view it on GitHub:
https://github.com/geany/geany/issues/848#issuecomment-168727853
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.geany.org/pipermail/github-comments/attachments/20160104/91cbe64f/attachment.html>


More information about the Github-comments mailing list