Class: Browsable::LSP::Handlers::DidChange

Inherits:
Object
  • Object
show all
Defined in:
lib/browsable/lsp/handlers/did_change.rb

Overview

Handles textDocument/didChange — re-audits a document as it is edited.

Instance Method Summary collapse

Constructor Details

#initialize(server) ⇒ DidChange

Returns a new instance of DidChange.



8
9
10
# File 'lib/browsable/lsp/handlers/did_change.rb', line 8

def initialize(server)
  @server = server
end

Instance Method Details

#call(params) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
# File 'lib/browsable/lsp/handlers/did_change.rb', line 12

def call(params)
  uri = params.dig("textDocument", "uri")
  return unless uri

  # Full-sync mode: the final content change carries the whole document.
  text = Array(params["contentChanges"]).last&.fetch("text", nil)
  return if text.nil?

  @server.store(uri, text)
  @server.publish_diagnostics(uri, text)
end