SF.net SVN: geany: [2759] trunk
ntrel at users.sourceforge.net
ntrel at xxxxx
Mon Jul 7 11:38:17 UTC 2008
Revision: 2759
http://geany.svn.sourceforge.net/geany/?rev=2759&view=rev
Author: ntrel
Date: 2008-07-07 04:38:15 -0700 (Mon, 07 Jul 2008)
Log Message:
-----------
Make line breaking work with multi-line comment completion and
'Newline strips trailing spaces' pref.
Modified Paths:
--------------
trunk/ChangeLog
trunk/src/editor.c
Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog 2008-07-07 11:09:23 UTC (rev 2758)
+++ trunk/ChangeLog 2008-07-07 11:38:15 UTC (rev 2759)
@@ -2,6 +2,9 @@
* tagmanager/haskell.c:
Fix infinite loop when parsing datatypes (fixes #2011356).
+ * src/editor.c:
+ Make line breaking work with multi-line comment completion and
+ 'Newline strips trailing spaces' pref.
2008-07-05 Enrico Tröger <enrico(dot)troeger(at)uvena(dot)de>
Modified: trunk/src/editor.c
===================================================================
--- trunk/src/editor.c 2008-07-07 11:09:23 UTC (rev 2758)
+++ trunk/src/editor.c 2008-07-07 11:38:15 UTC (rev 2759)
@@ -339,13 +339,30 @@
c = sci_get_char_at(sci, --pos);
if (c == GDK_space)
{
- gint indent_size = sci_get_line_indentation(sci, line);
+ gint col, len, diff;
+ const gchar *eol = editor_get_eol_char(doc);
/* break the line after the space */
- sci_insert_text(sci, pos + 1, editor_get_eol_char(doc));
+ sci_insert_text(sci, pos + 1, eol);
+ line++;
- if (doc->auto_indent)
- sci_set_line_indentation(sci, line + 1, indent_size);
+ /* remember distance from end of line (we use column position in case
+ * the previous line gets altered, such as removing trailing spaces). */
+ pos = sci_get_current_position(sci);
+ len = sci_get_line_length(sci, line);
+ col = sci_get_col_from_position(sci, pos);
+ diff = len - col;
+
+ /* set position as if user had pressed return */
+ pos = sci_get_position_from_line(sci, line);
+ sci_set_current_position(sci, pos, FALSE);
+ /* add indentation, comment multilines, etc */
+ on_new_line_added(doc);
+
+ /* correct cursor position (might not be at line end) */
+ pos = sci_get_position_from_line(sci, line);
+ pos += sci_get_line_length(sci, line) - diff;
+ sci_set_current_position(sci, pos, FALSE);
return;
}
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the Commits
mailing list