Skip to content

Commit

Permalink
Fix false diagnostics showing up on startup
Browse files Browse the repository at this point in the history
Fixes #132
  • Loading branch information
JohnnyMorganz committed Sep 17, 2022
1 parent 52792f1 commit 0f99d6d
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 0 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
- Sync to upstream Luau 0.545
- Inlay hints for variables will no longer show if the type hint string is the same as the variable name (i.e., `local tbl = {}`, the hint `: tbl` will no longer show) ([#137](https://github.com/JohnnyMorganz/luau-lsp/issues/137))

### Fixed

- Fixed false document diagnostics showing up for opened tabs when VSCode is first started ([#132](https://github.com/JohnnyMorganz/luau-lsp/issues/132))

## [1.9.2] - 2022-09-06

### Changed
Expand Down
1 change: 1 addition & 0 deletions src/Workspace.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,7 @@ void WorkspaceFolder::initialize()

void WorkspaceFolder::setupWithConfiguration(const ClientConfiguration& configuration)
{
isConfigured = true;
if (configuration.sourcemap.enabled)
{
if (!isNullWorkspace() && !updateSourceMap())
Expand Down
1 change: 1 addition & 0 deletions src/include/LSP/Workspace.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ class WorkspaceFolder
lsp::DocumentUri rootUri;
WorkspaceFileResolver fileResolver;
Luau::Frontend frontend;
bool isConfigured = false;

public:
WorkspaceFolder(std::shared_ptr<Client> client, const std::string& name, const lsp::DocumentUri& uri)
Expand Down
6 changes: 6 additions & 0 deletions src/operations/Diagnostics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@

lsp::DocumentDiagnosticReport WorkspaceFolder::documentDiagnostics(const lsp::DocumentDiagnosticParams& params)
{
if (!isConfigured)
{
lsp::DiagnosticServerCancellationData cancellationData{/*retriggerRequest: */ true};
throw JsonRpcException(lsp::ErrorCode::ServerCancelled, "server not yet received configuration for diagnostics", cancellationData);
}

// TODO: should we apply a resultId and return an unchanged report if unchanged?
lsp::DocumentDiagnosticReport report;
std::unordered_map<std::string /* lsp::DocumentUri */, std::vector<lsp::Diagnostic>> relatedDiagnostics;
Expand Down

0 comments on commit 0f99d6d

Please sign in to comment.