Skip to content

Commit

Permalink
Fix jumping to qualified names
Browse files Browse the repository at this point in the history
  • Loading branch information
mrkkrp committed Jul 30, 2017
1 parent 00ca4d9 commit 2abd864
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
6 changes: 5 additions & 1 deletion haskell-commands.el
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
(require 'haskell-font-lock)
(require 'haskell-interactive-mode)
(require 'haskell-session)
(require 'haskell-string)
(require 'haskell-presentation-mode)
(require 'haskell-utils)
(require 'highlight-uses-mode)
Expand Down Expand Up @@ -469,7 +470,10 @@ Returns:
;;;###autoload
(defun haskell-mode-jump-to-def (ident)
"Jump to definition of identifier IDENT at point."
(interactive (list (haskell-ident-at-point)))
(interactive
(list
(haskell-string-drop-qualifier
(haskell-ident-at-point))))
(let ((loc (haskell-mode-find-def ident)))
(when loc
(haskell-mode-handle-generic-loc loc))))
Expand Down
8 changes: 8 additions & 0 deletions haskell-string.el
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,14 @@ See also `haskell-string-take'."
((< n 1) "")
(t (concat (substring string 0 (1- n)) ""))))

(defun haskell-string-drop-qualifier (ident)
"Drop qualifier from given identifier IDENT.
If the identifier is not qualified return it unchanged."
(or (and (string-match "^\\([^.]*\\.\\)*\\(?1:[^.]+\\)$" ident)
(match-string 1 ident))
ident))

(provide 'haskell-string)

;;; haskell-string.el ends here
2 changes: 1 addition & 1 deletion haskell.el
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@ If `haskell-process-load-or-reload-prompt' is nil, accept `default'."
Give optional NEXT-P parameter to override value of
`xref-prompt-for-identifier' during definition search."
(interactive "P")
(let ((ident (haskell-ident-at-point))
(let ((ident (haskell-string-drop-qualifier (haskell-ident-at-point)))
(tags-file-dir (haskell-cabal--find-tags-dir))
(tags-revert-without-query t))
(when (and ident
Expand Down

0 comments on commit 2abd864

Please sign in to comment.