Hi there.
---------- 8< -------------------- 8< ----------
static void reflow_paragraph(GeanyEditor *editor)
{
ScintillaObject *sci = editor->sci;
gboolean sel;
sci_start_undo_action(sci);
sel = sci_has_selection(sci);
if (!sel)
{
gint line, pos;
keybindings_send_command(GEANY_KEY_GROUP_SELECT,
GEANY_KEYS_SELECT_PARAGRAPH);
/* deselect last line break */
pos = sci_get_selection_end(sci);
line = sci_get_line_from_position(sci, pos);
pos = sci_get_line_end_position(sci, line - 1);
sci_set_selection_end(sci, pos);
}
split_lines(editor);
if (!sel)
sci_set_anchor(sci, -1);
sci_end_undo_action(sci);
}
---------- 8< -------------------- 8< ----------
One case is not handled there. When cursor is in the last paragraph, and
this last paragraph spans till the end of document (i.e., document contains
no trailing newlines), the paragraph itself contains no trailing newlines,
and it is wrong to deselect last line break.
The attached patch seems to solve this problem.
So many little problems and questions... I'm sorry I'm so annoying.
Best regards,
Eugene.diff --git a/src/keybindings.c b/src/keybindings.c
index 6b72ddc..d574e2a 100644
--- a/src/keybindings.c
+++ b/src/keybindings.c
@@ -2122,8 +2122,12 @@ static void reflow_paragraph(GeanyEditor *editor)
/* deselect last line break */
pos = sci_get_selection_end(sci);
line = sci_get_line_from_position(sci, pos);
- pos = sci_get_line_end_position(sci, line - 1);
- sci_set_selection_end(sci, pos);
+ if (line < sci_get_line_count(sci) - 1)
+ {
+ /* not last line */
+ pos = sci_get_line_end_position(sci, line - 1);
+ sci_set_selection_end(sci, pos);
+ }
}
split_lines(editor);
if (!sel)
_______________________________________________
Geany-devel mailing list
[email protected]
http://lists.uvena.de/cgi-bin/mailman/listinfo/geany-devel