Kaydet (Commit) bfd5587f authored tarafından Colomban Wendling's avatar Colomban Wendling

Merge pull request #852 from b4n/reflow-hang

Fix hang in reflow command (and small improvements around)
......@@ -2221,7 +2221,7 @@ static gint split_line(GeanyEditor *editor, gint column)
gint pos;
/* don't split on a trailing space of a line */
if (sci_get_char_at(sci, lend - 1) == GDK_space)
if (sci_get_char_at(sci, lend - 1) == ' ')
lend--;
/* detect when the line is short enough and no more splitting is needed */
......@@ -2232,7 +2232,7 @@ static gint split_line(GeanyEditor *editor, gint column)
found = FALSE;
for (pos = edge - 1; pos > lstart; pos--)
{
if (sci_get_char_at(sci, pos) == GDK_space)
if (sci_get_char_at(sci, pos) == ' ')
{
found = TRUE;
break;
......@@ -2242,19 +2242,21 @@ static gint split_line(GeanyEditor *editor, gint column)
{
for (pos = edge; pos < lend; pos++)
{
if (sci_get_char_at(sci, pos) == GDK_space)
if (sci_get_char_at(sci, pos) == ' ')
{
found = TRUE;
break;
}
}
}
if (!found)
/* don't split right before a space */
while (pos + 1 <= lend && sci_get_char_at(sci, pos + 1) == ' ')
pos++;
if (!found || pos >= lend)
break;
sci_set_current_position(sci, pos + 1, FALSE);
sci_cancel(sci); /* don't select from completion list */
sci_send_command(sci, SCI_NEWLINE);
sci_insert_text(sci, pos + 1, editor_get_eol_char(editor));
line++;
}
return line - start_line;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment