Skip to content

Commit

Permalink
Make sure the changes are flushed before sending notifications
Browse files Browse the repository at this point in the history
- revert delaying incremental changes

fix emacs-lsp/lsp-java#195
  • Loading branch information
yyoncho committed Feb 20, 2020
1 parent f6ec81b commit 34838cb
Showing 1 changed file with 21 additions and 8 deletions.
29 changes: 21 additions & 8 deletions lsp-mode.el
Expand Up @@ -2753,7 +2753,6 @@ callback will be executed only if the buffer was not modified.

ERROR-CALLBACK will be called in case the request has failed.
If NO-MERGE is non-nil, don't merge the results but return alist workspace->result."
(lsp--flush-delayed-changes)

(when cancel-token
(lsp-cancel-request-by-token cancel-token))
Expand Down Expand Up @@ -3658,18 +3657,25 @@ Added to `after-change-functions'."
(lambda (workspace)
(pcase (or lsp-document-sync-method
(lsp--workspace-sync-method workspace))
(1 (cl-pushnew (list lsp--cur-workspace
(1 (cl-pushnew (list workspace
(current-buffer)
(lsp--versioned-text-document-identifier)
(lsp--full-change-event))
lsp--delayed-requests
:test 'equal))
(2 (push (list lsp--cur-workspace
(current-buffer)
(lsp--versioned-text-document-identifier)
(lsp--text-document-content-change-event
start end length))
lsp--delayed-requests))))
(2
(lsp-notify "textDocument/didChange"
(list :textDocument (lsp--versioned-text-document-identifier)
:contentChanges (vector (lsp--text-document-content-change-event
start end length))))
;; TODO investigate why this does not work
;; (push (list workspace
;; (current-buffer)
;;
;; (lsp--text-document-content-change-event
;; start end length))
;; lsp--delayed-requests)
)))
(lsp-workspaces))
(when lsp--delay-timer (cancel-timer lsp--delay-timer))
(setq lsp--delay-timer (run-with-idle-timer
Expand Down Expand Up @@ -5304,8 +5310,15 @@ textDocument/didOpen for the new file."

(advice-add 'set-visited-file-name :around #'lsp--on-set-visited-file-name)

(defvar lsp--flushing-delayed-changes nil)

(defun lsp--send-no-wait (message proc)
"Send MESSAGE to PROC without waiting for further output."

(unless lsp--flushing-delayed-changes
(let ((lsp--flushing-delayed-changes t))
(lsp--flush-delayed-changes)))

(condition-case err
(process-send-string proc message)
('error (lsp--error "Sending to process failed with the following error: %s"
Expand Down

0 comments on commit 34838cb

Please sign in to comment.