branch: elpa/graphql-mode
commit 8b2fe766357a98fddeeb6283072456d93889cbac
Author: Tim Shiu <[email protected]>
Commit: Tim Shiu <[email protected]>
fix a recursive bug in graphql-current-operation
---
graphql-mode.el | 11 +++++++----
1 file changed, 7 insertions(+), 4 deletions(-)
diff --git a/graphql-mode.el b/graphql-mode.el
index 14ab2774a4..6fe9b7c731 100644
--- a/graphql-mode.el
+++ b/graphql-mode.el
@@ -127,12 +127,15 @@ of the variables used in the query."
(if (not (equal start end))
(buffer-substring-no-properties start end)
(save-excursion
- (let ((line (thing-at-point 'line t)))
+ (let ((saved-point (point))
+ (line (thing-at-point 'line t)))
(when (string-match-p (regexp-quote "}") line)
- (search-backward "}"))
+ (search-backward "}" (beginning-of-line)))
(when (string-match-p (regexp-quote "{") line)
- (search-forward "{"))
- (graphql-current-query))))))
+ (search-forward "{" (end-of-line)))
+ (if (= (point) saved-point)
+ nil
+ (graphql-current-query)))))))
(defun graphql-current-operation ()
"Return the name of the current graphql query."