changeset 2298:a3562a127cf6 vim73

When 'formatexpr' evaluates to non-zero fall back to internal formatting, also for "gq". (James Vega)
author Bram Moolenaar <bram@vim.org>
date Sun, 11 Jul 2010 17:35:50 +0200
parents 5ffe000a9ecf
children 92e31a1b0c2f
files runtime/doc/options.txt runtime/doc/todo.txt src/ops.c
diffstat 3 files changed, 8 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/runtime/doc/options.txt
+++ b/runtime/doc/options.txt
@@ -3126,8 +3126,10 @@ A jump table for the options with a shor
 	text beyond that limit.  This happens under the same conditions as
 	when internal formatting is used.  Make sure the cursor is kept in the
 	same spot relative to the text then!  The |mode()| function will
-	return "i" or "R" in this situation.  When the function returns
-	non-zero Vim will fall back to using the internal format mechanism.
+	return "i" or "R" in this situation.
+	
+	When the expression evaluates to non-zero Vim will fall back to using
+	the internal format mechanism.
 
 	The expression may be evaluated in the |sandbox|, see
 	|sandbox-option|.
--- a/runtime/doc/todo.txt
+++ b/runtime/doc/todo.txt
@@ -1093,7 +1093,6 @@ Vim 7.3:
 - Conceal feature: no update when moving to another window. (Dominique Pelle,
   2010 Jul 5)  Vince will look into it.
 Patches to possibly include:
-- Patch to improve javascript indenting. (Hari Kumar G, 2010 May 22)
 - Patch to use return value of 'formatexpr'. (James Vega, 2010 Jun 16)
 - Patch for gtk main_loop() to enable GtkFileChooser. (James Vega, 2010 Jun 28)
     Same as this one?  GTK: file chooser is disabled.  Patch by Tim Starling,
--- a/src/ops.c
+++ b/src/ops.c
@@ -4475,7 +4475,10 @@ op_formatexpr(oap)
 	redraw_curbuf_later(INVERTED);
 # endif
 
-    (void)fex_format(oap->start.lnum, oap->line_count, NUL);
+    if (fex_format(oap->start.lnum, oap->line_count, NUL) != 0)
+	/* As documented: when 'formatexpr' returns non-zero fall back to
+	 * internal formatting. */
+	op_format(oap, FALSE);
 }
 
     int