[Geany-devel] Little bug in "reflow paragraph" command

Eugene Arshinov earshinov at xxxxx
Sat Sep 12 21:20:47 UTC 2009

Hi there.

---------- 8< -------------------- 8< ----------

static void reflow_paragraph(GeanyEditor *editor)
	ScintillaObject *sci = editor->sci;
	gboolean sel;

	sel = sci_has_selection(sci);
	if (!sel)
		gint line, pos;

		/* 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 (!sel)
		sci_set_anchor(sci, -1);

---------- 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,
-------------- next part --------------
A non-text attachment was scrubbed...
Name: geany.5.patch
Type: text/x-patch
Size: 613 bytes
Desc: not available
URL: <http://lists.geany.org/pipermail/devel/attachments/20090913/13aad52d/attachment.bin>

More information about the Devel mailing list