DidChange notifies the file system that a file was changed.
(params *lsp.DidChangeTextDocumentParams)
| 29 | |
| 30 | // DidChange notifies the file system that a file was changed. |
| 31 | func (fs *MemFS) DidChange(params *lsp.DidChangeTextDocumentParams) error { |
| 32 | content, found := fs.get(params.TextDocument.URI) |
| 33 | if !found { |
| 34 | return errors.Errorf("received textDocument/didChange for unknown file %q", params.TextDocument.URI) |
| 35 | } |
| 36 | |
| 37 | content, err := applyContentChanges(params.TextDocument.URI, content, params.ContentChanges) |
| 38 | if err != nil { |
| 39 | return err |
| 40 | } |
| 41 | |
| 42 | fs.set(params.TextDocument.URI, content) |
| 43 | return nil |
| 44 | } |
| 45 | |
| 46 | func applyContentChanges(uri lsp.DocumentURI, content []byte, changes []lsp.TextDocumentContentChangeEvent) ([]byte, error) { |
| 47 | for _, change := range changes { |
no test coverage detected