Repository navigation
Description
Summary
For DAP variables with type: "string", the Variables view doesn't show the value text the adapter sent. LSP4IJ strips quote characters from both ends of it and then adds its own " around the rest. The stripping doesn't know about escapes, so quote characters that belong to the string content are lost:
- different strings look the same (
"test","'test'"and"''test''"are all shown as"test"), - non-empty strings look empty (
"'"is shown as""), - an escaped quote at the end is cut in half: the
"is removed but its\stays ('"'is shown as"\").
The Set Value editor (F2) isn't affected: it starts with the full value text, so the tree and F2 show different text for the same variable.
How to reproduce
A debug adapter that sends each string value as a complete string literal (double quotes, backslash escapes), for example a JavaScript adapter:
function stringDisplayExample() {
let plain = "test";
let singleEdges = "'test'";
let doubledEdges = "''test''";
let empty = "";
let singleOnly = "'";
let doubleEdges = '"test"';
debugger;
}
stringDisplayExample();- Debug this file with such an adapter and stop at
debugger. - Look at the local variables in the Variables view.
- Select
doubleEdgesand press F2.
The value text below is what the adapter put into Variable.value. In the DAP message this text is JSON-encoded once more; for doubleEdges the wire form is "value": "\"\\\"test\\\"\"".
| Variable | value text from the adapter |
Shown in LSP4IJ | Expected |
|---|---|---|---|
plain |
"test" |
"test" |
"test" |
singleEdges |
"'test'" |
"test" |
"'test'" |
doubledEdges |
"''test''" |
"test" |
"''test''" |
empty |
"" |
"" |
"" |
singleOnly |
"'" |
"" |
"'" |
doubleEdges |
"\"test\"" |
"\"test\" |
"\"test\"" |
F2 on doubleEdges starts with "\"test\"", which is correct.
Screenshots
Left: the source. Right: the Variables view. Each group is a separate function, so names repeat across groups. First group: different strings look the same. Second group: non-empty strings look empty, and a " content ends up as a lone \. Third group: escaped quotes at the end are shown without their closing "; quotes inside the text are kept.
Columns: source, Variables view, F2 editor. Rows: single (content is one '), double (content is "test" with double quotes), c (content is \"test\" with backslashes and double quotes). In all three rows the F2 editor starts with the complete literal; only the tree is wrong. (The screenshots show the initial editor text, not that each value was set.)
Cause
In the current code on main (the links are permalinks to the code as of 2026-11-13):
DebugAdapterVariableSupport.formatValue()callsremoveQuotes()for string variables. It removes all leading and trailing", then all leading and trailing', without checking that they pair and without looking at escapes.getValuePresentation()then wraps the result in anXStringValuePresentation, which adds"around it again.DAPValueModifier.getInitialValueEditorText()usesVariable.valueunchanged, which is why F2 is right.
So only the display is changed; the value in the debuggee and the setVariable request aren't.
removeQuotes came with #814 for #812, where vscode-js-debug's 'name' was shown as "'name'". It fixes the outer quotes there, but has the same effect on content quotes with js-debug: in #812's own example, name1 = "name" (sent as 'name') and name3 = "'name'" (sent as "'name'") are both shown as "name".
Expected behavior and a possible fix
Show the value text as the adapter sent it, including its quotes and escapes. The string color can stay.
A possible fix, in DebugAdapterVariableSupport:
formatValue(): drop the string branch that callsremoveQuotes(value), so it returnsvalueunchanged for every type.- Remove the private
removeQuotes()method; it has no other caller. getValuePresentation(): for string types, replacenew XStringValuePresentation(formattedValue)with anXValuePresentationwhoserenderValue()callsrenderer.renderValue(value, DefaultLanguageHighlighterColors.STRING). That keeps the string color but adds no quotes of its own.
Numbers, booleans and other types stay as they are. The js-debug value from #812 would then be shown as 'name', as it is in VS Code.
It shouldn't unescape the text or try to rebuild a literal from type: "string": LSP4IJ doesn't know the adapter's quoting rules, and the text comes from the adapter. A language-specific DebugAdapterVariableSupport can still override getValuePresentation() if it knows them.
Environment and limits
- IntelliJ IDEA 2026.3, a local LSP4IJ snapshot, and a local JavaScript debug adapter that sends string values as complete double-quoted literals. Screenshots taken on 2026-11-13.
- Not run with vscode-js-debug or other adapters; the Single/double quotes displayed not correctly in watch area when debug TypeScript file #812 case above is derived from js-debug's quoting and the
removeQuotescode. - The "Shown in LSP4IJ" column was checked against the
removeQuotesregular expressions and matches the screenshots.
Out of scope here, to keep this to the display: Set Value on lazy variables, on evaluate results and watches, and setExpression.
Claude Code found the cause and wrote this report from the source and the screenshots.


Activity
lagergren commentedon Nov 16, 2026
Thanks for the thorough analysis, @muescha. #1994 makes the fix you proposed: a string is shown in the string color exactly as the debug adapter sends it,
formatValue()returns the value unchanged, andremoveQuotes()is gone. Its tests cover the strings in your table and #812's, and 4 of the 5 fail onmain.fix: show a DAP string value as the debug adapter sends it (redhat-de…