Skip to content

Commit

Permalink
fix: order of updating doc to yamlls and local
Browse files Browse the repository at this point in the history
  • Loading branch information
qvalentin committed Oct 14, 2024
1 parent 90fe288 commit f2f76d4
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 9 deletions.
2 changes: 1 addition & 1 deletion internal/adapter/yamlls/document_sync.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ func (yamllsConnector Connector) DocumentDidChangeFullSync(doc *lsplocal.Templat
return
}

logger.Debug("Sending DocumentDidChange with full sync, current content:", doc.Content)
logger.Debug("Sending DocumentDidChange with full sync, current content:", string(doc.Content))
trimmedText := lsplocal.TrimTemplate(doc.Ast.Copy(), doc.Content)

params.ContentChanges = []lsp.TextDocumentContentChangeEvent{
Expand Down
4 changes: 2 additions & 2 deletions internal/handler/lang_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ type LangHandler interface {
DidOpen(ctx context.Context, params *lsp.DidOpenTextDocumentParams, helmlsConfig util.HelmlsConfiguration) (err error)
// DidSave is called when a document is saved, it must not update the document store
DidSave(ctx context.Context, params *lsp.DidSaveTextDocumentParams) (err error)
// DidChange is called when a document is changed, it must not update the document store
DidChange(ctx context.Context, params *lsp.DidChangeTextDocumentParams) (err error)
// PostDidChange is called when a document is changed, it must not update the document store
PostDidChange(ctx context.Context, params *lsp.DidChangeTextDocumentParams) (err error)

Configure(ctx context.Context, helmlsConfig util.HelmlsConfiguration)
GetDiagnostics(uri lsp.DocumentURI) []lsp.PublishDiagnosticsParams
Expand Down
2 changes: 1 addition & 1 deletion internal/handler/template_handler/text_document.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ func (h *TemplateHandler) DidSave(ctx context.Context, params *lsp.DidSaveTextDo
return nil
}

func (h *TemplateHandler) DidChange(ctx context.Context, params *lsp.DidChangeTextDocumentParams) (err error) {
func (h *TemplateHandler) PostDidChange(ctx context.Context, params *lsp.DidChangeTextDocumentParams) (err error) {
doc, ok := h.documents.GetTemplateDoc(params.TextDocument.URI)
if !ok {
return errors.New("Could not get document: " + params.TextDocument.URI.Filename())
Expand Down
6 changes: 2 additions & 4 deletions internal/handler/text_document.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,17 +43,15 @@ func (h *ServerHandler) DidSave(ctx context.Context, params *lsp.DidSaveTextDocu
}

func (h *ServerHandler) DidChange(ctx context.Context, params *lsp.DidChangeTextDocumentParams) (err error) {
handler, err := h.selectLangHandler(ctx, params.TextDocument.URI)
handler.DidChange(ctx, params)

doc, ok := h.documents.GetSyncDocument(params.TextDocument.URI)
if !ok {
return errors.New("Could not get document: " + params.TextDocument.URI.Filename())
}
// Synchronise changes into the doc's ContentChanges
doc.ApplyChanges(params.ContentChanges)

return nil
handler, err := h.selectLangHandler(ctx, params.TextDocument.URI)
return handler.DidChange(ctx, params)

Check failure on line 54 in internal/handler/text_document.go

View workflow job for this annotation

GitHub Actions / lint (1.22.4, ubuntu-latest)

handler.DidChange undefined (type LangHandler has no field or method DidChange)) (typecheck)

Check failure on line 54 in internal/handler/text_document.go

View workflow job for this annotation

GitHub Actions / lint (1.22.4, ubuntu-latest)

handler.DidChange undefined (type LangHandler has no field or method DidChange) (typecheck)

Check failure on line 54 in internal/handler/text_document.go

View workflow job for this annotation

GitHub Actions / tests (1.22.4, ubuntu-latest)

handler.DidChange undefined (type LangHandler has no field or method DidChange)

Check failure on line 54 in internal/handler/text_document.go

View workflow job for this annotation

GitHub Actions / tests (1.22.4, macos-latest)

handler.DidChange undefined (type LangHandler has no field or method DidChange)
}

func (h *ServerHandler) DidCreateFiles(ctx context.Context, params *lsp.CreateFilesParams) (err error) {
Expand Down
2 changes: 1 addition & 1 deletion internal/handler/yaml_handler/text_document.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
)

// DidChange implements handler.LangHandler.
func (h *YamlHandler) DidChange(ctx context.Context, params *protocol.DidChangeTextDocumentParams) (err error) {
func (h *YamlHandler) PostDidChange(ctx context.Context, params *protocol.DidChangeTextDocumentParams) (err error) {

Check failure on line 11 in internal/handler/yaml_handler/text_document.go

View workflow job for this annotation

GitHub Actions / lint (1.22.4, ubuntu-latest)

unused-parameter: parameter 'ctx' seems to be unused, consider removing or renaming it as _ (revive)
panic("unimplemented")
}

Expand Down

0 comments on commit f2f76d4

Please sign in to comment.