SF.net SVN: geany:[3224] trunk

ntrel at users.sourceforge.net ntrel at xxxxx
Thu Nov 13 17:22:23 UTC 2008


Revision: 3224
          http://geany.svn.sourceforge.net/geany/?rev=3224&view=rev
Author:   ntrel
Date:     2008-11-13 17:22:23 +0000 (Thu, 13 Nov 2008)

Log Message:
-----------
Make editor_insert_text_block() transform any \n newline chars with
the correct line ending string.

Modified Paths:
--------------
    trunk/ChangeLog
    trunk/src/editor.c

Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog	2008-11-13 17:19:52 UTC (rev 3223)
+++ trunk/ChangeLog	2008-11-13 17:22:23 UTC (rev 3224)
@@ -30,6 +30,9 @@
  * src/utils.c:
    Make API function utils_string_replace_all() able to make
    replacements that match the search string.
+ * src/editor.c:
+   Make editor_insert_text_block() transform any \n newline chars with
+   the correct line ending string.
 
 
 2008-11-12  Enrico Tröger  <enrico(dot)troeger(at)uvena(dot)de>

Modified: trunk/src/editor.c
===================================================================
--- trunk/src/editor.c	2008-11-13 17:19:52 UTC (rev 3223)
+++ trunk/src/editor.c	2008-11-13 17:22:23 UTC (rev 3224)
@@ -1716,10 +1716,10 @@
 }
 
 
-/* Insert text, replacing \t tab chars with the correct indent width.
+/* Insert text, replacing \t tab chars with the correct indent width, and \n newline
+ * chars with the correct line ending string.
  * @param text Intended as e.g. "if (1)\n\tdo_something();"
  * @param cursor_index If >= 0, the index into @a text to place the cursor.
- * @todo Correct for CRLF line endings.
  * @warning Make sure all \t tab chars in @a text are intended as indent widths,
  * NOT any hard tabs (you get those when copying document text with the Tabs
  * & Spaces indent mode set).
@@ -1741,6 +1741,9 @@
 	if (cursor_index >= 0)
 		g_string_insert(buf, cursor_index, cur_marker);	/* remember cursor pos */
 
+	/* transform line endings */
+	utils_string_replace_all(buf, "\n", editor_get_eol_char(editor));
+
 	/* transform tabs into indent widths in spaces */
 	whitespace = g_strnfill(editor_get_indent_prefs(editor)->width, ' ');
 	utils_string_replace_all(buf, "\t", whitespace);
@@ -1789,7 +1792,7 @@
 	/* we use only spaces so it works with editor_insert_text_block(). */
 	line = sci_get_line_from_position(sci, pos);
 	lindent = g_strnfill(sci_get_line_indentation(sci, line), ' ');
-	setptr(lindent, g_strconcat(editor_get_eol_char(editor), lindent, NULL));
+	setptr(lindent, g_strconcat("\n", lindent, NULL));
 
 	/* remove the typed word, it will be added again by the used auto completion
 	 * (not really necessary but this makes the auto completion more flexible,


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