<p>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.</p>

<div class="highlight highlight-source-diff"><pre><span class="pl-c1">diff --git a/src/keybindings.c b/src/keybindings.c</span>
index 8913c57..4da0dba 100644
<span class="pl-md">--- a/src/keybindings.c</span>
<span class="pl-mi1">+++ b/src/keybindings.c</span>
<span class="pl-mdr">@@ -2247,6 +2249,11 @@</span> static gint split_line(GeanyEditor *editor, gint column)
                if (!found)
                        break;

<span class="pl-mi1">+               /* don't split on trailing spaces, which would mess up with auto-indent</span>
<span class="pl-mi1">+                * and possibly lead to infinite loop */</span>
<span class="pl-mi1">+               while (pos + 1 < lend && sci_get_char_at(sci, pos + 1) == GDK_space)</span>
<span class="pl-mi1">+                       pos ++;</span>
<span class="pl-mi1">+</span>
                sci_set_current_position(sci, pos + 1, FALSE);
                sci_cancel(sci); /* don't select from completion list */
                sci_send_command(sci, SCI_NEWLINE);</pre></div>

<p>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?</p>

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

<p style="font-size:small;-webkit-text-size-adjust:none;color:#666;">—<br>Reply to this email directly or <a href="https://github.com/geany/geany/issues/848#issuecomment-168727853">view it on GitHub</a>.<img alt="" height="1" src="https://github.com/notifications/beacon/ABDrJ8fTeKYMnpPtw8eXb51570bdnxDlks5pWpeUgaJpZM4G9vAU.gif" width="1" /></p>
<div itemscope itemtype="http://schema.org/EmailMessage">
<div itemprop="action" itemscope itemtype="http://schema.org/ViewAction">
  <link itemprop="url" href="https://github.com/geany/geany/issues/848#issuecomment-168727853"></link>
  <meta itemprop="name" content="View Issue"></meta>
</div>
<meta itemprop="description" content="View this Issue on GitHub"></meta>
</div>