Module: Requests::TextDocument::DidChange

Extended by:
DidChange
Included in:
DidChange
Defined in:
lib/holistic/language_server/requests/text_document/did_change.rb

Constant Summary collapse

BuildDocumentChange =
->(params) do
  ::Holistic::Document::Unsaved::Change.new(
    range_length: params.dig("rangeLength"),
    text: params.dig("text"),
    start_line: params.dig("range", "start", "line"),
    start_column: params.dig("range", "start", "character"),
    end_line: params.dig("range", "end", "line"),
    end_column: params.dig("range", "end", "character")
  )
end

Instance Method Summary collapse

Instance Method Details

#call(request) ⇒ Object



18
19
20
21
22
23
24
25
26
27
28
# File 'lib/holistic/language_server/requests/text_document/did_change.rb', line 18

def call(request)
  file_path = Format::FileUri.extract_path(request.param("textDocument", "uri"))

  unsaved_document = request.application.unsaved_documents.find(file_path)

  request.param("contentChanges").map(&BuildDocumentChange).each do |change|
    unsaved_document.apply_change(change)
  end

  request.respond_with(nil)
end