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) ...@@ -2221,7 +2221,7 @@ static gint split_line(GeanyEditor *editor, gint column)
gint pos; gint pos;
/* don't split on a trailing space of a line */ /* 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--; lend--;
/* detect when the line is short enough and no more splitting is needed */ /* 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) ...@@ -2232,7 +2232,7 @@ static gint split_line(GeanyEditor *editor, gint column)
found = FALSE; found = FALSE;
for (pos = edge - 1; pos > lstart; pos--) 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; found = TRUE;
break; break;
...@@ -2242,19 +2242,21 @@ static gint split_line(GeanyEditor *editor, gint column) ...@@ -2242,19 +2242,21 @@ static gint split_line(GeanyEditor *editor, gint column)
{ {
for (pos = edge; pos < lend; pos++) for (pos = edge; pos < lend; pos++)
{ {
if (sci_get_char_at(sci, pos) == GDK_space) if (sci_get_char_at(sci, pos) == ' ')
{ {
found = TRUE; found = TRUE;
break; 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; break;
sci_set_current_position(sci, pos + 1, FALSE); sci_insert_text(sci, pos + 1, editor_get_eol_char(editor));
sci_cancel(sci); /* don't select from completion list */
sci_send_command(sci, SCI_NEWLINE);
line++; line++;
} }
return line - start_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