Skip to content

Commit

Permalink
fix: Notify diagnostic consumers after document close
Browse files Browse the repository at this point in the history
  • Loading branch information
jirimosinger authored Apr 21, 2023
1 parent b18d192 commit 5bf404b
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
13 changes: 13 additions & 0 deletions language_server/test/regress_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,19 @@ TEST(regress_test, behaviour_error)
EXPECT_EQ(diagnostics[0]["code"].get<std::string>(), "S0003");

mess_p.notfs.clear();

notf = make_notification(
"textDocument/didClose", R"#({"textDocument":{"uri":"file:///c%3A/test/behaviour_error.hlasm"}})#"_json);
s.message_received(notf);
EXPECT_FALSE(ws_mngr.idle_handler());

auto notfs_it = std::find_if(mess_p.notfs.begin(), mess_p.notfs.end(), [](const auto& msg_notification) {
return msg_notification["method"] == "textDocument/publishDiagnostics";
});
ASSERT_NE(notfs_it, mess_p.notfs.end());
EXPECT_EQ((*notfs_it)["params"]["diagnostics"].size(), (size_t)0);

mess_p.notfs.clear();
}

const static std::vector<nlohmann::json> messages = {
Expand Down
5 changes: 3 additions & 2 deletions parser_library/src/workspace_manager_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -522,8 +522,9 @@ class workspace_manager::impl final : public diagnosable_impl, workspaces::exter
m_work_queue.emplace_back(work_item {
next_unique_id(),
&ows,
std::function<utils::task()>(
[document_loc, &ws = ows.ws]() mutable { return ws.did_close_file(std::move(document_loc)); }),
std::function<utils::task()>([this, document_loc, &ws = ows.ws]() mutable {
return ws.did_close_file(std::move(document_loc)).then([this]() { notify_diagnostics_consumers(); });
}),
{},
work_item_type::file_change,
});
Expand Down

0 comments on commit 5bf404b

Please sign in to comment.