Skip to content

Commit 316062b

Browse files
committed
fix: contextCache not being updated correctly
1 parent 7a30050 commit 316062b

File tree

1 file changed

+7
-13
lines changed

1 file changed

+7
-13
lines changed

server/src/server.ts

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -210,21 +210,15 @@ connection.onHover((params: HoverParams): Hover | null => {
210210

211211
connection.onRequest("source/publishInfo", (info: { [uri: string]: Context }) => {
212212
for (const [uri, context] of Object.entries(info)) {
213-
const document = documents.get(uri);
214-
if (document) {
215-
let oldContext = contextCache.get(uri);
216-
if (!oldContext) {
217-
oldContext = context;
218-
contextCache.set(uri, context);
219-
astCache.delete(uri);
213+
const oldContext = contextCache.get(uri);
214+
if (!oldContext || context.chapter !== oldContext.chapter || context.prepend !== oldContext.prepend) {
215+
// Context has been added or changed for this URI
216+
contextCache.set(uri, context);
217+
astCache.delete(uri);
218+
const document = documents.get(uri);
219+
if (document) {
220220
validateTextDocument(document)
221221
}
222-
// Check if context changed
223-
else if (context.chapter !== oldContext.chapter || context.prepend !== oldContext.prepend) {
224-
contextCache.set(uri, context);
225-
astCache.delete(uri);
226-
validateTextDocument(document);
227-
}
228222
}
229223
}
230224

0 commit comments

Comments
 (0)