shader-language-server (antaalt/shader-sense) v1.3.0 panics with
"byte index N is out of bounds" in symbol_parser.rs when a file is first
parsed as an include dependency (raw CRLF bytes via std::fs::read_to_string)
and then later opened as a main document. watch_main_file replaces the
cached module's content with the client-provided didOpen text but does
not re-parse the tree-sitter tree, so if the client normalized line
endings (CRLF -> LF) the stored tree references byte offsets past the
new content length and the next documentSymbol query slices out of bounds.
Python's default text-mode open performs universal-newlines translation,
which is what was shrinking the text Serena sent in didOpen. Override
open_file in HlslLanguageServer to preload LSPFileBuffer contents with
newline="" so the bytes sent to the server match what it reads from disk,
sidestepping the stale-tree condition entirely. The fix is scoped to
hlsl_language_server.py; no core files are touched.
Verified with a 28-shader sweep over a Unity HDRP workspace where the
crash was 100% reproducible (TerrainRayMarch.shader -> TerrainSDF.hlsl);
all files now return symbols cleanly. The upstream bug should still be
fixed in shader-sense (watch_main_file should call update_module rather
than assigning .content), but this workaround unblocks Windows users
immediately.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Improve README:
* Move LS deps back to prerequisites
* Remove incorrect config path (redundant anyway, because user sees it upon init)
* Some wording changes
Subprocesses were not cleaned up, in particular.
* Rename SerenaAgent.shutdown to on_shutdown, because it is really a shutdown handler;
it did not perform a shutdown.
* Add new method shutdown which is now called from both sites (and which performs
the full shutdown)
* Manage the process instance used for the dashboard viewer and shut it down
explicitly.
* Initialise all variables used during shutdown immeditaly (avoiding errors when
shutdown is triggered during init)
Even though the parameter is after the separator `--`, newer versions (>2.1.76)
fail to add the MCP server and interpret the arguments directly.
Fixes#1279