Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ jobs:
- name: Run tests
run: |
eask install-deps

eask test buttercup

eask package
eask install
eask compile
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@
dist
.eask
*.elc
*~
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Changelog

## Unreleased

- Fix issue with `view_ediff` displaying empty buffers in ediff. #86
4 changes: 3 additions & 1 deletion eca-diff.el
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,9 @@ ROOTS may be passed for path relativization if desired.

This function tries to be Doom-compatible when Emacs runs Doom popup
system (it ignores those popup rules for the generated ediff buffers)."
(let* ((parsed (eca-diff-parse-unified-diff diff))
(let* (;; ediff expects `\n` line endings.
(diff (replace-regexp-in-string "\r\n" "\n" diff))
(parsed (eca-diff-parse-unified-diff diff))
(orig (plist-get parsed :original))
(new (plist-get parsed :new))
(buf-orig (generate-new-buffer (format "*eca-diff-orig:%s*" path)))
Expand Down
39 changes: 39 additions & 0 deletions test/eca-diff-test.el
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
;;; -*- lexical-binding: t; -*-
(require 'buttercup)
(require 'eca-diff)

(defconst native-eol
(if (eq system-type 'windows-nt)
"\r\n"
"\n")
"Native end-of-line string for the current operating system.")

(describe "eca-diff-show-ediff"
:var ((insert-orig (symbol-function 'insert))
(contents '()))
(before-each
(spy-on 'insert
:and-call-fake (lambda (&rest args)
(apply insert-orig args)
(push (list (buffer-name) (buffer-string)) contents )
)))
(it "can display unified diffs with native EOLs"
(let* ((inhibit-message t)
(path "/a/path")
(diff (string-join '("@@ -1,3 +1,4 @@"
"-Line 1"
"-Line 2"
"+Line 1 modified"
"+Line 2"
"+Line 3 added")
native-eol)))

;; We expect this function to call `insert` twice.
(eca-diff-show-ediff path diff)
(expect (reverse contents)
:to-equal
`((,(format "*eca-diff-orig:%s*" path) "Line 1
Line 2")
(,(format "*eca-diff-new:%s*" path) "Line 1 modified
Line 2
Line 3 added"))))))
Loading