branch: elpa/idris-mode
commit 978d800bf442564961813ee239e71e00ac6cfc42
Author: Marek L <[email protected]>
Commit: Marek L <[email protected]>

    [xref] Improve `xref-backend-identifier-at-point` to handle edgecases
    
    returned by `idris-name-at-point`.
    
    Example:
    `"Foo.Bar" -> "Bar"`
    `"Foo.($)" -> "$"
    `"Prelude." -> "Prelude"
---
 idris-xref.el | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/idris-xref.el b/idris-xref.el
index f8914116e7..ea2bd4d22f 100644
--- a/idris-xref.el
+++ b/idris-xref.el
@@ -61,8 +61,14 @@ set `idris-xref-idris-source-location' instead."
   'idris)
 
 (cl-defmethod xref-backend-identifier-at-point ((_backend (eql idris)))
-  "Alias for `idris-name-at-point'."
-  (idris-name-at-point))
+  "Return the relevant identifier at point.
+
+Parse and sanitizes output from `idris-name-at-point'."
+  ;; name-at in idris2 doesn't like namespace and () around the thing
+  ;; When (idris-name-at-point) returns `Foo.(Bar)` we want to search for "Bar"
+  (let ((parts (cl-remove-if #'string-empty-p
+                             (split-string (idris-name-at-point) "\\."))))
+    (string-trim (car (last parts)) "[({]" "[})]")))
 
 (cl-defmethod xref-backend-definitions ((_backend (eql idris)) symbol)
   "Return a list of Xref objects candidates matching SYMBOL."

Reply via email to