Skip to content

Commit

Permalink
Fixed lsp opened being sent with empty content when opening file
Browse files Browse the repository at this point in the history
  • Loading branch information
Nimaoth committed May 14, 2024
1 parent 165cdfd commit 4fea500
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 9 deletions.
Binary file modified config/absytree_config_wasm.wasm
Binary file not shown.
2 changes: 1 addition & 1 deletion src/text/language/language_server_lsp.nim
Original file line number Diff line number Diff line change
Expand Up @@ -472,7 +472,7 @@ method connect*(self: LanguageServerLSP, document: Document) =

let document = document.TextDocument

log lvlInfo, fmt"Connecting document '{document.filename}'"
log lvlInfo, fmt"Connecting document (loadingAsync: {document.isLoadingAsync}) '{document.filename}'"

if document.isLoadingAsync:
var handle = new Id
Expand Down
13 changes: 5 additions & 8 deletions src/text/text_document.nim
Original file line number Diff line number Diff line change
Expand Up @@ -883,7 +883,12 @@ proc newTextDocument*(

let autoStartServer = self.configProvider.getValue("editor.text.auto-start-language-server", false)

self.content = content
self.languageServer = languageServer.mapIt(it)

if load:
self.load()

if self.languageServer.getSome(ls):
# debugf"register save handler '{self.filename}'"
let callback = proc (targetFilename: string): Future[void] {.async.} =
Expand All @@ -895,13 +900,6 @@ proc newTextDocument*(
elif createLanguageServer and autoStartServer:
asyncCheck self.getLanguageServer()

# debugf"using language for {filename}: {value}, {self.indentStyle}"

self.content = content

if load:
self.load()

method deinit*(self: TextDocument) =
logScope lvlInfo, fmt"[deinit] Destroying text document '{self.filename}'"
if self.highlightQuery.isNotNil:
Expand Down Expand Up @@ -975,7 +973,6 @@ proc loadAsync(self: TextDocument, ws: WorkspaceFolder, reloadTreesitter: bool =
self.content = catch ws.loadFile(self.filename).await:
log lvlError, &"[loadAsync] Failed to load workspace file {self.filename}: {getCurrentExceptionMsg()}\n{getCurrentException().getStackTrace()}"
""

if not ws.isFileReadOnly(self.filename).await:
self.readOnly = false

Expand Down

0 comments on commit 4fea500

Please sign in to comment.