Skip to content

Instantly share code, notes, and snippets.

@mattn
Created October 14, 2011 02:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mattn/1286099 to your computer and use it in GitHub Desktop.
Save mattn/1286099 to your computer and use it in GitHub Desktop.
diff -r f530aef0d959 src/ex_getln.c
--- a/src/ex_getln.c Wed Oct 12 22:02:14 2011 +0200
+++ b/src/ex_getln.c Fri Oct 14 11:25:08 2011 +0900
@@ -121,6 +121,12 @@
static int ex_window __ARGS((void));
#endif
+static int
+#ifdef __BORLANDC__
+_RTLENTRYF
+#endif
+sort_func_compare __ARGS((const void *s1, const void *s2));
+
/*
* getcmdline() - accept a command line starting with firstc.
*
@@ -3286,6 +3292,21 @@
return check_abbr(c, ccline.cmdbuff, ccline.cmdpos, 0);
}
+ static int
+#ifdef __BORLANDC__
+_RTLENTRYF
+#endif
+sort_func_compare(s1, s2)
+ const void *s1;
+ const void *s2;
+{
+ char_u *p1 = *(char **)s1, *p2 = *(char **)s2;
+
+ if (*p1 != '<' && *p2 == '<') return -1;
+ if (*p1 == '<' && *p2 != '<') return 1;
+ return STRCMP(p1, p2);
+}
+
/*
* Return FAIL if this is not an appropriate context in which to do
* completion of anything, return OK if it is (even if there are no matches).
@@ -4734,8 +4755,16 @@
}
/* Sort the results. Keep menu's in the specified order. */
- if (xp->xp_context != EXPAND_MENUNAMES && xp->xp_context != EXPAND_MENUS)
- sort_strings(*file, *num_file);
+ if (xp->xp_context != EXPAND_MENUNAMES && xp->xp_context != EXPAND_MENUS) {
+ if (xp->xp_context == EXPAND_EXPRESSION
+ || xp->xp_context == EXPAND_FUNCTIONS
+ || xp->xp_context == EXPAND_USER_FUNC)
+ /* <SNR> functions should be sorted to the end. */
+ qsort((void *)*file, (size_t)*num_file, sizeof(char_u *),
+ sort_func_compare);
+ else
+ sort_strings(*file, *num_file);
+ }
#ifdef FEAT_CMDL_COMPL
/* Reset the variables used for special highlight names expansion, so that
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment