Skip to content

Why the diff order reverse? #2

Description

@snowman

Description

By debug suffixes data of function backup-walker-refresh, its structure is (".~3~" ".~2~" ".~1~")

Every time you

  1. press "p" (prev changes) to increase(+) index pointer, like from ".~3~" to ".~2~" (for older changes)
  2. press "n" (next changes) to decrease(-) index pointer, like from ".~2~" to ".~3~" (for newer changes)

The first item ".~3~" is most recent, this is different from git notation like HEAD~3

So in your code, left-file with (setq left-file (concat prefix (nth (1- index) suffixes))) means more recent file, right-file means older file

But you passed them to function diff-no-select in reversed order

(if (eq index 0)
(setq left-file (cdr (assq :original-file backup-walker-data-alist))
left-version "orig")
(setq left-file (concat prefix (nth (1- index) suffixes))
left-version (format "%i" (backup-walker-get-version left-file))))
(setq diff-buf (diff-no-select left-file right-file nil 'noasync))


see? you write (diff old new switches no-async)

(or (fboundp 'diff-no-select)
(defun diff-no-select (old new &optional switches no-async)
(save-window-excursion (diff old new switches no-async))
(get-buffer-create "*Diff*")))


What you expect?

(setq diff-buf (diff-no-select left-file right-file nil 'noasync))

should be

(setq diff-buf (diff-no-select right-file left-file nil 'noasync))

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions