|
51 | 51 |
|
52 | 52 | (defun lsp-ivy--workspace-symbol (workspaces prompt initial-input)
|
53 | 53 | "Search against WORKSPACES with PROMPT and INITIAL-INPUT."
|
54 |
| - (let (;; contains current user input, followed by the string representations |
55 |
| - ;; of all currently available candidates |
56 |
| - (candidates) |
57 |
| - (current-request-id)) |
| 54 | + (let ((candidates nil) |
| 55 | + (current-request-id nil)) |
58 | 56 | (ivy-read
|
59 | 57 | prompt
|
60 |
| - (lambda (user-input &rest args) |
61 |
| - (if (string= user-input (car candidates)) |
62 |
| - (mapcar |
63 |
| - (lambda (it) (lsp-ivy--format-symbol-match it)) |
64 |
| - (cdr candidates)) |
65 |
| - (ignore |
66 |
| - (with-lsp-workspaces workspaces |
67 |
| - (let ((request (lsp-make-request |
68 |
| - "workspace/symbol" |
69 |
| - (list :query user-input)))) |
70 |
| - (when current-request-id |
71 |
| - (lsp--cancel-request |
72 |
| - current-request-id)) |
73 |
| - (setq current-request-id |
74 |
| - (plist-get request :id)) |
75 |
| - (lsp-send-request-async |
76 |
| - request |
77 |
| - (lambda (incoming-candidates) |
78 |
| - (setq candidates |
79 |
| - (cons user-input |
80 |
| - incoming-candidates)) |
81 |
| - (let (ivy--old-text) |
82 |
| - (ivy--exhibit))) |
83 |
| - :mode 'detached)))))) |
| 58 | + (lambda (user-input) |
| 59 | + (with-lsp-workspaces workspaces |
| 60 | + (let ((request (lsp-make-request |
| 61 | + "workspace/symbol" |
| 62 | + (list :query user-input)))) |
| 63 | + (when current-request-id |
| 64 | + (lsp--cancel-request |
| 65 | + current-request-id)) |
| 66 | + (setq current-request-id |
| 67 | + (plist-get request :id)) |
| 68 | + (lsp-send-request-async |
| 69 | + request |
| 70 | + (lambda (incoming-candidates) |
| 71 | + (ivy-update-candidates |
| 72 | + (mapcar |
| 73 | + #'lsp-ivy--format-symbol-match |
| 74 | + (setq candidates incoming-candidates)))) |
| 75 | + :mode 'detached))) |
| 76 | + 0) |
84 | 77 | :dynamic-collection t
|
85 | 78 | :require-match t
|
86 | 79 | :initial-input initial-input
|
87 | 80 | :action (lambda (result)
|
88 | 81 | (let ((match
|
89 |
| - (--find |
90 |
| - (string-equal result (lsp-ivy--format-symbol-match it)) |
91 |
| - ;; KLUDGE: remove current query, find candidate |
92 |
| - ;; corresponding to selected candidate by linear search |
93 |
| - (cdr candidates)))) |
94 |
| - (when match (lsp-ivy--workspace-symbol-action match))))))) |
| 82 | + (cl-find-if |
| 83 | + (lambda (it) (string-equal result (lsp-ivy--format-symbol-match it))) |
| 84 | + candidates))) |
| 85 | + (when match |
| 86 | + (lsp-ivy--workspace-symbol-action match))))))) |
95 | 87 |
|
96 | 88 | ;;;###autoload
|
97 | 89 | (defun lsp-ivy-workspace-symbol (arg)
|
|
0 commit comments