Skip to content

Commit 92078ca

Browse files
authored
Do not use :cancel-handler (#2309)
- Fixes #2305 The issue isthat when using :cancel-handler we leak cleanup handlers. Putting a log in lsp--cancel-request proves that. Currently the cancel-handler does not kick due to tick mode so it is fine to switch to that code
1 parent 452b7bd commit 92078ca

File tree

1 file changed

+10
-14
lines changed

1 file changed

+10
-14
lines changed

lsp-mode.el

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4302,20 +4302,16 @@ Applies on type formatting."
43024302
(let ((ch last-command-event))
43034303
(when (or (eq (string-to-char first-trigger-characters) ch)
43044304
(cl-find ch more-trigger-characters :key #'string-to-char))
4305-
(-let [(callback cleanup-fn) (lsp--create-apply-text-edits-handlers)]
4306-
(lsp-request-async "textDocument/onTypeFormatting"
4307-
(lsp-merge (lsp-make-document-on-type-formatting-params
4308-
:ch (char-to-string ch)
4309-
:position (lsp--cur-position))
4310-
(lsp--make-document-formatting-params))
4311-
(lambda (text-edits)
4312-
(funcall callback text-edits)
4313-
(funcall cleanup-fn))
4314-
:error-handler (lambda (err)
4315-
(funcall cleanup-fn)
4316-
(error (lsp:json-error-message err)))
4317-
:cancel-handler cleanup-fn
4318-
:mode 'tick)))))
4305+
(lsp-request-async "textDocument/onTypeFormatting"
4306+
(lsp-make-document-on-type-formatting-params
4307+
:text-document (lsp--text-document-identifier)
4308+
:options (lsp-make-formatting-options
4309+
:tab-size (symbol-value (lsp--get-indent-width major-mode))
4310+
:insert-spaces (if indent-tabs-mode :json-false t))
4311+
:ch (char-to-string ch)
4312+
:position (lsp--cur-position))
4313+
#'lsp--apply-text-edits
4314+
:mode 'tick))))
43194315

43204316

43214317
;; links

0 commit comments

Comments
 (0)