Skip to content

Commit

Permalink
Send changes immediately instead of queueing them
Browse files Browse the repository at this point in the history
For incremental change mode, all the changes in a `textDocument/didChange`
message are interpreted as applying to the same version of a particular
document.

But each emacs change corresponds to the state of the document when the change
happens. So harmonise the expectations by sending each change in its own
message.

closes emacs-lsp#112
  • Loading branch information
alanz committed Aug 30, 2017
1 parent 1d29d6b commit 3d230b7
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion lsp-methods.el
Original file line number Diff line number Diff line change
Expand Up @@ -733,7 +733,14 @@ to a text document."
(setq lsp--has-changes t)
(lsp--rem-idle-timer)
(when (eq lsp--server-sync-method 'incremental)
(lsp--push-change (lsp--text-document-content-change-event start end length)))
;; (lsp--push-change (lsp--text-document-content-change-event start end length)))

;; Each change needs to be wrt to the current doc, so send immediately.
;; Otherwise we need to adjust the coordinates of the new change according
;; to the cumulative changes already queued.
(progn
(lsp--push-change (lsp--text-document-content-change-event start end length))
(lsp--send-changes lsp--cur-workspace)))
(if (lsp--workspace-change-timer-disabled lsp--cur-workspace)
(lsp--send-changes lsp--cur-workspace)
(lsp--set-idle-timer lsp--cur-workspace))))
Expand Down

0 comments on commit 3d230b7

Please sign in to comment.