Skip to content

Commit

Permalink
fix: include source code in updateUri
Browse files Browse the repository at this point in the history
  • Loading branch information
sockmaster27 committed Jan 28, 2024
1 parent 7a677d6 commit e9d3d86
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
4 changes: 3 additions & 1 deletion server/src/engine/flix.ts
Original file line number Diff line number Diff line change
Expand Up @@ -220,14 +220,16 @@ export function addUri(uri: string) {
* If this URI has not already been added to the workspace via {@linkcode addUri},
* it will be ignored, making it safe to call this function on any file.
*/
export function updateUri(uri: string) {
export function updateUri(uri: string, src: string) {
if (!currentWorkspaceFiles.has(uri)) {
return
}

// Including the source code in the job is necessary because the file might not yet have been saved
const job: jobs.Job = {
request: jobs.Request.apiAddUri,
uri,
src,
}

// Skip the delay to improve auto-complete responsiveness
Expand Down
6 changes: 4 additions & 2 deletions server/src/handlers/handlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -157,13 +157,15 @@ export function handleExit() {

export function handleSave(params: TextDocumentChangeEvent<TextDocument>) {
if (engine.compileOnSaveEnabled()) {
engine.updateUri(params.document.uri)
const document = params.document
engine.updateUri(document.uri, document.getText())
}
}

export function handleChangeContent(params: TextDocumentChangeEvent<TextDocument>) {
if (engine.compileOnChangeEnabled()) {
engine.updateUri(params.document.uri)
const document = params.document
engine.updateUri(document.uri, document.getText())
}
}

Expand Down

0 comments on commit e9d3d86

Please sign in to comment.