mirror of
https://github.com/Myzel394/config-lsp.git
synced 2025-06-19 15:35:28 +02:00
fix(server): Fix didChange and didOpen
This commit is contained in:
parent
7a92594135
commit
cc92cacd48
@ -6,7 +6,10 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func ClearDiagnostics(context *glsp.Context, uri protocol.DocumentUri) {
|
func ClearDiagnostics(context *glsp.Context, uri protocol.DocumentUri) {
|
||||||
go context.Notify(
|
// Diagnostics are sent synchronously, as sending them async
|
||||||
|
// could result in a race condition when we send diagnostics
|
||||||
|
// to the client.
|
||||||
|
context.Notify(
|
||||||
protocol.ServerTextDocumentPublishDiagnostics,
|
protocol.ServerTextDocumentPublishDiagnostics,
|
||||||
protocol.PublishDiagnosticsParams{
|
protocol.PublishDiagnosticsParams{
|
||||||
URI: uri,
|
URI: uri,
|
||||||
|
@ -18,6 +18,11 @@ func TextDocumentDidChange(context *glsp.Context, params *protocol.DidChangeText
|
|||||||
language := shared.Handler.GetLanguageForDocument(params.TextDocument.URI)
|
language := shared.Handler.GetLanguageForDocument(params.TextDocument.URI)
|
||||||
|
|
||||||
content := params.ContentChanges[0].(protocol.TextDocumentContentChangeEventWhole).Text
|
content := params.ContentChanges[0].(protocol.TextDocumentContentChangeEventWhole).Text
|
||||||
|
|
||||||
|
if _, found := shared.OpenedFiles[params.TextDocument.URI]; !found {
|
||||||
|
// The file couldn't be initialized when opening it,
|
||||||
|
// so we will try it again here
|
||||||
|
|
||||||
newLanguage, err := initFile(
|
newLanguage, err := initFile(
|
||||||
context,
|
context,
|
||||||
content,
|
content,
|
||||||
@ -45,19 +50,7 @@ func TextDocumentDidChange(context *glsp.Context, params *protocol.DidChangeText
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
switch *language {
|
return TextDocumentDidOpen(context, params)
|
||||||
case shared.LanguageFstab:
|
|
||||||
return fstab.TextDocumentDidOpen(context, params)
|
|
||||||
case shared.LanguageSSHDConfig:
|
|
||||||
return sshdconfig.TextDocumentDidOpen(context, params)
|
|
||||||
case shared.LanguageSSHConfig:
|
|
||||||
return sshconfig.TextDocumentDidOpen(context, params)
|
|
||||||
case shared.LanguageWireguard:
|
|
||||||
return wireguard.TextDocumentDidOpen(context, params)
|
|
||||||
case shared.LanguageHosts:
|
|
||||||
return hosts.TextDocumentDidOpen(context, params)
|
|
||||||
case shared.LanguageAliases:
|
|
||||||
return aliases.TextDocumentDidOpen(context, params)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -61,9 +61,6 @@ func initFile(
|
|||||||
uri protocol.DocumentUri,
|
uri protocol.DocumentUri,
|
||||||
advertisedLanguage string,
|
advertisedLanguage string,
|
||||||
) (*shared.SupportedLanguage, error) {
|
) (*shared.SupportedLanguage, error) {
|
||||||
println("Initializing the file")
|
|
||||||
println(advertisedLanguage)
|
|
||||||
println(uri)
|
|
||||||
language, err := utils.DetectLanguage(content, advertisedLanguage, uri)
|
language, err := utils.DetectLanguage(content, advertisedLanguage, uri)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user