-
Notifications
You must be signed in to change notification settings - Fork 275
Description
Environment
- VS Code Version: Latest (January 2026)
- AL Language Extension Version: (check via Extensions panel)
- Business Central Version: v26.5 OnPrem
- OS: Windows 11
Description
When using GitHub Copilot in agent mode, certain file operations can cause the AL Language Server to retain stale diagnostic data. Specifically, when the agent:
- Deletes a file using
run_in_terminal(PowerShellRemove-Item) - Recreates it using
create_filetool (VS Code file creation API) - The new file contains a syntax error
- Agent fixes the error using
replace_string_in_filetool (in-place edit)
...the Problems panel continues displaying the original errors even though the file is now correct.
Reproduction Steps
-
Have an existing AL file open in VS Code, e.g.,
MyPage.Page.al -
Copilot agent executes
run_in_terminal:Remove-Item "c:\path\to\MyPage.Page.al" -Force
-
Agent immediately executes
create_filetool to recreate the file with same path, but the new content has a syntax error (e.g., duplicate line, extra parenthesis) -
Problems panel correctly shows the syntax error(s)
-
Agent executes
replace_string_in_filetool to fix the syntax error via in-place edit -
Bug: Problems panel still shows the original error(s)
Key Detail: Tool Chain Interaction
This appears to be an interaction issue between:
- Terminal execution (
run_in_terminal-> PowerShellRemove-Item) - VS Code file API (
create_filetool) - AL Language Server (file watcher / diagnostics cache)
The replace_string_in_file tool correctly updates the language server (errors would clear if ONLY this tool was used). The issue is that the prior delete+create sequence puts the language server in a state where subsequent in-place edits don't properly refresh the diagnostics cache.
Evidence
AL: Build(Ctrl+Shift+B) shows successful compilation with 0 errors- VS Code's
get_errorsAPI returns empty array (correct) - Problems panel UI shows stale errors (incorrect)
- Error line numbers in Problems panel may not match actual file content
Workaround
Developer: Reload Window clears the stale cache.
Hypothesis
The AL Language Server's file watcher may not properly handle the rapid sequence of:
- File deleted (external via terminal)
- File created (via VS Code API)
- File modified (via VS Code API)
The delete event from the terminal may not be fully processed before the create event arrives, causing the language server to retain state from the pre-delete file version.
Related Issue
This may be related to #7891 (AL languages internal cache is not always correctly refreshed), which describes similar stale cache behavior with external file modifications.
Why This Matters
AI coding agents (Copilot, Cursor, etc.) increasingly use these tool patterns. As agent-assisted development grows, this interaction between terminal operations and VS Code file APIs will become more common.