Skip to content

fix(lsp): clear ghost diagnostics on file deletion (LSP-FIX-015) - #194

Merged
PythonWoods-Dev merged 15 commits into
mainfrom
fix/lsp-state-and-dqs
Jul 28, 2026
Merged

fix(lsp): clear ghost diagnostics on file deletion (LSP-FIX-015)#194
PythonWoods-Dev merged 15 commits into
mainfrom
fix/lsp-state-and-dqs

Conversation

@PythonWoods-Dev

Copy link
Copy Markdown
Contributor

Objective

Eliminates the LSP ghost diagnostics state leak: when a Markdown file is deleted, the VS Code PROBLEMS panel immediately clears its stale entries.

Root Cause

_handle_file_changes (type=3) removed the file from the engine cache but never sent textDocument/publishDiagnostics with diagnostics:[]. VS Code retains ghost diagnostics until the next full workspace scan.

Changes

src/zenzic/lsp/server.py

On workspace/didChangeWatchedFiles type=3:

  • Evicts URI from documents.documents, dirty_documents, and overlay.
  • Sends textDocument/publishDiagnostics with diagnostics:[] immediately.
  • Uses continue to prevent re-adding the deleted URI to dirty_documents.

tests/test_lsp.py

New test: test_file_deletion_clears_ghost_diagnostics

Acceptance Criteria

  • ✅ Deleting a file immediately clears its errors from the VS Code PROBLEMS panel.
  • just verify passes 100% (1498 passed, DQS 98/100).

Signed-off-by: PythonWoods <gianluca.catalano@gmail.com>
Signed-off-by: PythonWoods <gianluca.catalano@gmail.com>
…et pattern resolution

Signed-off-by: PythonWoods <gianluca.catalano@gmail.com>
On workspace/didChangeWatchedFiles type=3 (Deleted), the LSP server now:
- Evicts the deleted URI from documents, dirty_documents, and overlay.
- Sends textDocument/publishDiagnostics with diagnostics:[] immediately.
- Uses 'continue' to prevent re-scheduling the deleted file for analysis.

Without this fix, VS Code retained stale (ghost) diagnostics in the
PROBLEMS panel until the next full workspace scan.

Acceptance Criteria (LSP-FIX-015 Fix 1):
- Deleting a file immediately clears its errors from the VS Code PROBLEMS panel.

Unit test: tests/test_lsp.py::test_file_deletion_clears_ghost_diagnostics

Signed-off-by: PythonWoods <gianluca.catalano@gmail.com>
… (CORE-FEAT-001)

- Z121 (Missing Href): Marked fixable=False in codes.py. Removed HtmlMissingHrefMutation since missing URLs require human context.
- Z505 (Untagged Code Block): Marked fixable=True in codes.py. Implemented UntaggedCodeBlockMutation to inject 'text' language specifier into untagged fenced blocks.
- Z108 (Empty Link Text): Marked fixable=True in codes.py. Updated EmptyLinkTextMutation to inject 'TODO' placeholder label.
- Updated CLI fix and LSP codeAction dispatchers accordingly.
- Added comprehensive unit tests in test_redteam_remediation.py, test_custom_rules.py, test_fix.py, and test_lsp.py.

Signed-off-by: PythonWoods <gianluca.catalano@gmail.com>
- Explicitly route Z108, Z505, and Z603 diagnostics to EmptyLinkTextMutation, UntaggedCodeBlockMutation, and DeadSuppressionMutation.
- Complete removal of Z121 handler.
- Added test_lsp_code_action_z108 to tests/test_lsp.py.

Signed-off-by: PythonWoods <gianluca.catalano@gmail.com>
Signed-off-by: PythonWoods <gianluca.catalano@gmail.com>
Signed-off-by: PythonWoods <gianluca.catalano@gmail.com>
Signed-off-by: PythonWoods <gianluca.catalano@gmail.com>
…S-ALIGN-001)

Signed-off-by: PythonWoods <gianluca.catalano@gmail.com>
…te (LSP-FEAT-003)

Signed-off-by: PythonWoods <gianluca.catalano@gmail.com>
Signed-off-by: PythonWoods <gianluca.catalano@gmail.com>
Signed-off-by: PythonWoods <gianluca.catalano@gmail.com>
Signed-off-by: PythonWoods <gianluca.catalano@gmail.com>
Signed-off-by: PythonWoods <gianluca.catalano@gmail.com>

# Conflicts:
#	.bumpversion.toml
#	.github/ISSUE_TEMPLATE/security_vulnerability.yml
#	.pre-commit-hooks.yaml
#	CHANGELOG.md
#	CITATION.cff
#	README.md
#	RELEASE.md
#	mkdocs.yml
#	pyproject.toml
#	src/zenzic/__init__.py
#	src/zenzic/cli/_standalone.py
#	uv.lock
@github-advanced-security

Copy link
Copy Markdown

You are seeing this message because GitHub Code Scanning has recently been set up for this repository, or this pull request contains the workflow file for the Code Scanning tool.

What Enabling Code Scanning Means:

  • The 'Security' tab will display more code scanning analysis results (e.g., for the default branch).
  • Depending on your configuration and choice of analysis tool, future pull requests will be annotated with code scanning analysis results.
  • You will be able to see the analysis results for the pull request's branch on this overview once the scans have completed and the checks have passed.

For more information about GitHub Code Scanning, check out the documentation.

@PythonWoods-Dev
PythonWoods-Dev merged commit af55b55 into main Jul 28, 2026
8 checks passed
@PythonWoods-Dev
PythonWoods-Dev deleted the fix/lsp-state-and-dqs branch July 28, 2026 15:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants