Module: Requests::TextDocument::DidClose

Extended by:
DidClose
Included in:
DidClose
Defined in:
lib/holistic/language_server/requests/text_document/did_close.rb

Instance Method Summary collapse

Instance Method Details

#call(request) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/holistic/language_server/requests/text_document/did_close.rb', line 7

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

  request.application.unsaved_documents.find(path)&.then do |unsaved_document|
    request.application.unsaved_documents.delete(path)
    
    if unsaved_document.has_unsaved_changes?
      unsaved_document.restore_original_content!

      ::Holistic::Ruby::Parser::LiveEditing::ProcessFileChanged.call(
        application: request.application,
        file_path: unsaved_document.path,
        content: unsaved_document.content
      )
    end
  end

  request.respond_with(nil)
end