pherrymason / c3-lsp

Language Server for C3 Language
https://pherrymason.github.io/c3-lsp/
GNU General Public License v3.0
78 stars 10 forks source link

Reporting error diagnostics by using `c3c build --test` #57

Closed pherrymason closed 3 months ago

pherrymason commented 3 months ago

By calling c3c build --test on the project, LSP could get some initial diagnostics showing compiler errors as the user modifies its project.

image

Reference: https://github.com/c3lang/c3c/issues/1329

joshring commented 3 months ago

In order to fix this locally I moved

state.SetCalculateDiagnostics(true) inside of runDiagnostics to it's first line

joshring commented 3 months ago

though that lead to a regression in behaviour image

nikpivkin commented 3 months ago

Hi @pherrymason ! @joshring is right, since calculatingDiagnostics is set when diagnostics is run, subsequent calls to diagnostics cannot override the previous one. Does this boolean flag make sense if debouncing is used?

pherrymason commented 3 months ago

You are both right, calculatingDiagnostics is causing the bad behaviour. I removed its usage completely as @nikpivkin is right, it might not be needed if I'm already using a debounce. Thank you!