Skip to content

Commit

Permalink
Bugfix: Handle aliases with {} notation in mixed order (#277)
Browse files Browse the repository at this point in the history
Previously `alchemist-scope-aliases` would only recognize all aliases when the
ones declared with the `{}` where declared strictly before the normal ones.

See `test/alchemist-scope-test.el` for a failing test case.

That happened because both searches where happening inside the same
`save-excursion` block.

This commit fixes that bug and now allows aliases declared in both ways to be
mixed in any order.
  • Loading branch information
rranelli authored and tonini committed Jan 5, 2017
1 parent d90689a commit b23c0c3
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
5 changes: 4 additions & 1 deletion alchemist-scope.el
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,10 @@
(as (if (match-string 3) (match-string 3) nil))
(as (if as as (car (last (split-string alias "\\."))))))
(setq aliases (append aliases (list (list (alchemist-utils-remove-dot-at-the-end alias)
(alchemist-utils-remove-dot-at-the-end as))))))))
(alchemist-utils-remove-dot-at-the-end as))))))))))
(save-excursion
(when (alchemist-scope-inside-module-p)
(end-of-line)
;; alias definition like:
;;
;; alias List.Chars.{Atom, Float}
Expand Down
3 changes: 3 additions & 0 deletions test/alchemist-scope-test.el
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,8 @@ end")
(alchemist-scope-aliases))))
(should (equal (list '("Phoenix.Router.Scope" "Scope")
'("Phoenix.Router.Resource" "Special")
'("List.Chars.BitString" "BitString")
'("List.Chars.Integer" "Integer")
'("List.Chars.Atom" "Atom")
'("List.Chars.Float" "Float"))
(with-temp-buffer
Expand All @@ -134,6 +136,7 @@ defmodule Phoenix.Router do
alias List.Chars.{Atom, Float}
alias Phoenix.Router.Resource, as: Special
alias List.Chars.{BitString, Integer}
alias Phoenix.Router.Scope
end")
Expand Down

0 comments on commit b23c0c3

Please sign in to comment.