|
17 | 17 |
|
18 | 18 | ;; You should have received a copy of the GNU General Public License |
19 | 19 | ;; along with this program. If not, see <https://www.gnu.org/licenses/>. |
| 20 | +;; Package-Requires: ((emacs "27.2")) |
20 | 21 |
|
21 | 22 | ;;; Commentary: |
22 | 23 | ;; Tests for the integration of the LSP mode and SonarLint language server |
@@ -180,7 +181,7 @@ If nil, use python-mode by default." |
180 | 181 | '("cpp:S995")))) |
181 | 182 |
|
182 | 183 | (defun lsp-sonarlint--find-descr-action-at-point () |
183 | | - "Find the 'get rule description' code action for the issue at point." |
| 184 | + "Find the `get rule description' code action for the issue at point." |
184 | 185 | (seq-find (lambda (action) (string-match-p "description" (gethash "title" action))) |
185 | 186 | (lsp-code-actions-at-point))) |
186 | 187 |
|
@@ -213,19 +214,22 @@ If nil, use python-mode by default." |
213 | 214 | (lsp-sonarlint--go-to-first-diag diags) |
214 | 215 | (let ((descr-action (lsp-sonarlint--find-descr-action-at-point))) |
215 | 216 | (let ((description-opened nil)) |
216 | | - (cl-flet ((check-opened-buffer |
217 | | - (buf) |
218 | | - (when (lsp-sonarlint--buf-has-rule-descr-p buf) |
219 | | - (setq description-opened t)))) |
| 217 | + (cl-flet ((check-opened-buffer (buf) |
| 218 | + (when (lsp-sonarlint--buf-has-rule-descr-p buf) |
| 219 | + (setq description-opened t)))) |
220 | 220 | (unwind-protect |
221 | 221 | (progn |
222 | 222 | (advice-add 'shr-render-buffer :before #'check-opened-buffer) |
223 | | - (sit-for 1) |
224 | | - (lsp-execute-code-action descr-action) |
225 | 223 | (with-timeout (8 (error "Timeout waiting for rule description")) |
226 | 224 | (while (not description-opened) |
| 225 | + ;; Repeat the request multiple times because SonarLint |
| 226 | + ;; might get distracted with other requests and "forget" to |
| 227 | + ;; respond |
| 228 | + (lsp-execute-code-action descr-action) |
227 | 229 | (message "still waiting") |
228 | | - (sit-for 0.1))) |
| 230 | + (sit-for 0.3))) |
229 | 231 | (should description-opened)) |
230 | 232 | (advice-remove 'shr-render-buffer #'check-opened-buffer)))))) |
231 | 233 | 'python-mode)) |
| 234 | + |
| 235 | +;;; integration.el ends here |
0 commit comments