Skip to content

Commit

Permalink
fix(lsp): Request document sync on open/close
Browse files Browse the repository at this point in the history
Without sending `open_close: true` to the client, it may not issue an `textDocument/didOpen` event with document text to allow the diagnostics and text cache to be initialized after opening, but prior to editing, the document.  Format requests also emit "Format request arrived before text synchronized" in this state.  The didClose event probably also doesn't arrive to see cache entries removed.

Observed in neovim 0.8.3 using internal client, while vim with prabirshrestha/vim-lsp sends the event regardless (but does not currently issue didClose).
  • Loading branch information
merrilymeredith committed Mar 5, 2023
1 parent a8bd8a4 commit 697a002
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
3 changes: 2 additions & 1 deletion lib/standard/lsp/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ def for(name)
diagnostic_provider: true,
execute_command_provider: true,
text_document_sync: Proto::Interface::TextDocumentSyncOptions.new(
change: Proto::Constant::TextDocumentSyncKind::FULL
change: Proto::Constant::TextDocumentSyncKind::FULL,
open_close: true
)
)
))
Expand Down
2 changes: 1 addition & 1 deletion test/standard/runners/lsp_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def test_server_initializes_and_responds_with_proper_capabilities
assert_equal msgs.first, {
id: 2,
result: {capabilities: {
textDocumentSync: {change: 1},
textDocumentSync: {openClose: true, change: 1},
documentFormattingProvider: true,
diagnosticProvider: true,
executeCommandProvider: true
Expand Down

0 comments on commit 697a002

Please sign in to comment.