2014/06/26 23:09, Ben Fritz <fritzophre...@gmail.com> wrote:
> Could this be fixed, by using (l2.lnum - l1.lnum) rather than
> (l1.lnum - l2.lnum) if lines are equal, when using reverse sort?

Well... the change is easy (see the patch below), but I think the
current behavior of :sort! is a 'feature', not a bug. Changing
its behavior will break many existing scripts.
For example, test57 fails after the patch.




diff -r e11fcef66289 src/ex_cmds.c
--- a/src/ex_cmds.c     Wed Jun 25 22:55:38 2014 +0200
+++ b/src/ex_cmds.c     Fri Jun 27 00:31:05 2014 +0900
@@ -277,6 +277,7 @@
static int      sort_ic;                /* ignore case */
static int      sort_nr;                /* sort on number */
static int      sort_rx;                /* sort on regex instead of skipping it 
*/
+static int     sort_rv;                /* reverse sort */

static int      sort_abort;             /* flag to indicate if sorting has been 
interrupted */

@@ -338,7 +339,7 @@

    /* If two lines have the same value, preserve the original line order. */
    if (result == 0)
-       return (int)(l1.lnum - l2.lnum);
+       return sort_rv ? (int)(l2.lnum - l1.lnum) : (int)(l1.lnum - l2.lnum);
    return result;
}

@@ -380,6 +381,7 @@
    if (nrs == NULL)
        goto sortend;

+    sort_rv = eap->forceit;
    sort_abort = sort_ic = sort_rx = sort_nr = sort_oct = sort_hex = 0;

    for (p = eap->arg; *p != NUL; ++p)




-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_dev+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Raspunde prin e-mail lui