SF.net SVN: geany: [2169] trunk

eht16 at users.sourceforge.net eht16 at xxxxx
Sat Jan 12 13:01:45 UTC 2008


Revision: 2169
          http://geany.svn.sourceforge.net/geany/?rev=2169&view=rev
Author:   eht16
Date:     2008-01-12 05:01:43 -0800 (Sat, 12 Jan 2008)

Log Message:
-----------
Don't add '>' when auto completing HTML tags when it's already there.
Fix wrong indentation when '{' and '}' are on the same line.      

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

Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog	2008-01-12 12:22:46 UTC (rev 2168)
+++ trunk/ChangeLog	2008-01-12 13:01:43 UTC (rev 2169)
@@ -1,13 +1,17 @@
 2008-01-12  Enrico Tröger  <enrico(dot)troeger(at)uvena(dot)de>
 
- * src/keyfile.c: Try to fix changing message window height when using
-                  full screen (closes #1869415).
+ * src/keyfile.c:
+   Try to fix changing message window height when using full screen
+   (closes #1869415).
  * src/printing.c:
    Avoid double status message if print dialog was cancelled.
    Print status messages in status-changed handler.
  * Makefile.am, po/POTFILES.skip:
    Add POTFILES.skip to ignore files with translatable strings.
    Make "distcheck" working.
+ * src/editor.c:
+   Don't add '>' when auto completing HTML tags when it's already there.
+   Fix wrong indentation when '{' and '}' are on the same line.
 
 
 2008-01-11  Nick Treleaven  <nick(dot)treleaven(at)btinternet(dot)com>

Modified: trunk/src/editor.c
===================================================================
--- trunk/src/editor.c	2008-01-12 12:22:46 UTC (rev 2168)
+++ trunk/src/editor.c	2008-01-12 13:01:43 UTC (rev 2169)
@@ -510,7 +510,8 @@
 
 	prev_line = sci_get_line_from_position(sci, pos);
 
-	if (! use_this_line) prev_line--;
+	if (! use_this_line)
+		prev_line--;
 	len = sci_get_line_length(sci, prev_line);
 	linebuf = sci_get_line(sci, prev_line);
 
@@ -527,7 +528,9 @@
 			if (! lexer_has_braces(sci))
 				break;
 
-			if (linebuf[i] == '{')
+			// i == (len - 1) prevents wrong indentation after lines like
+			// "	{ return bless({}, shift); }" (Perl)
+			if (linebuf[i] == '{' && i == (len - 1))
 			{
 				do_indent(indent, sizeof(indent), &j, doc->use_tabs);
 				break;
@@ -1347,10 +1350,7 @@
 		// User typed something like "<br/>"
 		return FALSE;
 
-	if (ch == '/')
-		str_found = utils_find_open_xml_tag(sel, pos - min, TRUE);
-	else
-		str_found = utils_find_open_xml_tag(sel, pos - min, FALSE);
+	str_found = utils_find_open_xml_tag(sel, pos - min, (ch == '/'));
 
 	// when found string is something like br, img or another short tag, quit
 	if (utils_str_equal(str_found, "br")
@@ -1366,11 +1366,18 @@
 		return FALSE;
 	}
 
-	if (strlen(str_found) > 0)
+	if (*str_found != '\0')
 	{
 		gchar *to_insert;
 		if (ch == '/')
-			to_insert = g_strconcat(str_found, ">", NULL);
+		{
+			gchar *gt = ">";
+			// if there is already a '>' behind the cursor, don't add it
+			if (sci_get_char_at(sci, pos) == '>')
+				gt = "";
+
+			to_insert = g_strconcat(str_found, gt, NULL);
+		}
 		else
 			to_insert = g_strconcat("</", str_found, ">", NULL);
 		sci_start_undo_action(sci);
@@ -1387,7 +1394,6 @@
 		return TRUE;
 	}
 
-
 	g_free(str_found);
 	return FALSE;
 }


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