summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSteve Purcell <steve@sanityinc.com>2019-07-05 08:35:14 +1200
committerSteve Purcell <steve@sanityinc.com>2019-07-05 08:37:23 +1200
commitb4df0b62fef356fb826184b88cf70b35541718c3 (patch)
treed4e1f3b26bdff330ce423b793c26ac58fb0b6018
parent88a8a580b95fbd33a16b2f10d01f21d581a5b213 (diff)
Add test and provide different fix for #184.
This reverts commit 78ab0095621150833292dfb2aa0e1338f9044ea7. This is now fixed more generally by 629ce581.
-rw-r--r--ledger-complete.el15
-rw-r--r--test/complete-test.el19
2 files changed, 24 insertions, 10 deletions
diff --git a/ledger-complete.el b/ledger-complete.el
index 1964818..569031e 100644
--- a/ledger-complete.el
+++ b/ledger-complete.el
@@ -76,20 +76,15 @@ If nil, full account names are offered for completion."
(defun ledger-payees-in-buffer ()
- "Scan buffer and return list of all payees.
-Omit the payee on the current line if it is the only instance of
-that payee in the buffer."
- ;; We omit the payee on the current line because this function is part of
- ;; `ledger-complete'. If we include the current line's payee, then anything
- ;; matches, which makes it hard to do completion, see bug#181.
+ "Scan buffer and return list of all payees."
(let ((origin (point))
payees-list)
(save-excursion
(goto-char (point-min))
- (while (re-search-forward ledger-payee-any-status-regex nil t) ;; matches first line
- (unless (or (<= (point-at-bol) origin (point-at-eol)) ; current line
- (and (>= origin (match-beginning 0))
- (< origin (match-end 0))))
+ (while (re-search-forward
+ ledger-payee-any-status-regex nil t) ;; matches first line
+ (unless (and (>= origin (match-beginning 0))
+ (< origin (match-end 0)))
(setq payees-list (cons (match-string-no-properties 3)
payees-list))))) ;; add the payee
;; to the list
diff --git a/test/complete-test.el b/test/complete-test.el
index 87ff248..368f5b9 100644
--- a/test/complete-test.el
+++ b/test/complete-test.el
@@ -103,6 +103,25 @@ http://bugs.ledger-cli.org/show_bug.cgi?id=252"
2010/04/09 payee
bloop"))))
+(ert-deftest ledger-complete/test-complete-single-payee ()
+ "https://github.com/ledger/ledger-mode/issues/181"
+ :tags '(complete regress)
+ (ledger-tests-with-temp-file
+ "2019/06/28 Foobar
+ Expenses:Baz 11.99 CAD
+ Assets:Cash
+
+2019/06/20 Foo"
+ (goto-char (point-max))
+ (call-interactively 'completion-at-point)
+ (should
+ (equal (buffer-string)
+ "2019/06/28 Foobar
+ Expenses:Baz 11.99 CAD
+ Assets:Cash
+
+2019/06/20 Foobar"))))
+
(ert-deftest ledger-complete/test-find-accounts-in-buffer ()
(let ((ledger "*** Expenses
account Expenses:Accomodation