Skip to content

fix: show a DAP string value as the debug adapter sends it - #1994

Merged
lagergren merged 1 commit into
redhat-developer:mainfrom
lagergren:fix/dap-show-string-values-as-sent
Nov 16, 2026
Merged

lagergren merged 1 commit into
redhat-developer:mainfrom
lagergren:fix/dap-show-string-values-as-sent

Conversation

@lagergren

@lagergren lagergren commented Nov 16, 2026 •

Copy link
Copy Markdown
Collaborator

@angelozerr, a fix for #1992, which @muescha found and analysed, for 0.30.0. It changes how #814 shows strings for #812: vscode-js-debug's strings now keep their single quotes, as they do in VS Code. If you'd rather keep the old look for some debug adapters, a DebugAdapterVariableSupport can still override getValuePresentation().

The problem

For a variable whose type is string, formatValue() removed every " and then every ' from both ends of the value, and XStringValuePresentation put the rest in double quotes of its own. Quotes that belong to the string were lost:

The debug adapter sends Shown before Shown now
"test" "test" "test"
"'test'" "test" "'test'"
"'" "" "'"
"\"test\"" "\"test\" "\"test\""
'name' (vscode-js-debug) "name" 'name'
"'name'" (vscode-js-debug, the string 'name') "name" "'name'"

So in #812's example, name1 = "name" and name3 = "'name'" were both shown as "name".

The fix

A string is shown in the string color, exactly as the debug adapter sends it, as VS Code shows it. Only the adapter knows the quotes and escapes of its language, and the Set Value editor (F2) already starts with this text, so the tree and the editor now agree. formatValue() returns the value unchanged, and the private removeQuotes() is gone. Numbers, booleans and other values are shown as before, and a plugin that needs other rules can still override getValuePresentation() or formatValue().

What users will see:

  • vscode-js-debug's strings keep their single quotes ('name'), as in VS Code.
  • A debug adapter that sends a string without quotes has it shown without quotes.
  • IntelliJ no longer marks control characters in a string, or cuts it off after 1,000 characters, as it already doesn't for values of other types.

Tests

DebugAdapterVariableSupportTest checks what the Variables view is asked to render: the strings of #1992 and #812, a type String, and a number, a boolean and an object. 4 of its 5 tests fail on main. It and the other DAP variable and descriptor tests pass locally: 71 tests in 13 classes.

Fixes #1992

The Variables view removed every " and then every ' from both ends of a
string value, and put the rest in double quotes of its own. Quotes that
belong to the string were lost: "'test'" was shown as "test", "'" as "",
and an escaped quote at the end lost its quote but kept its backslash.

A string is now shown in the string color as the debug adapter sends
it, with the quotes and escapes of its language, as VS Code shows it.
vscode-js-debug's strings keep their single quotes.

Fixes redhat-developer#1992
@lagergren lagergren added this to the 0.30.0 milestone Nov 16, 2026
@coderabbitai

coderabbitai Bot commented Nov 16, 2026 •

Copy link
Copy Markdown

No actionable comments were generated in the recent review.

Summary

Summary by CodeRabbit

  • Bug Fixes
    • String values in the debugger now retain the quotes and escape characters provided by the debug adapter.
    • String types are recognized regardless of capitalization, while other value types keep their existing presentation.

String variables now display the value supplied by the DAP server, including quotes and escapes, with string syntax highlighting. The formatter returns values unchanged, or an empty string for null. Tests cover string formatting and existing render categories for other values.

Changes: DAP string rendering

Layer / File(s) Summary
Preserve and render DAP string values
src/main/java/com/redhat/devtools/lsp4ij/dap/descriptors/DebugAdapterVariableSupport.java, src/test/java/com/redhat/devtools/lsp4ij/dap/descriptors/DebugAdapterVariableSupportTest.java
String values use a custom presentation with string coloring. formatValue returns the DAP value unchanged, or an empty string for null; the quote-stripping helper is removed. Tests cover quotes, escapes, case variations in the string type, other value render categories, and formatted values.

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix · Severity of issue fixed: Medium

Suggested reviewers: angelozerr

Merge Risk: Minimal · up to 54c1c

String variables now appear in the Variables view exactly as the debug adapter sends them, quotes and escapes included. The change is small, display-only, and covered by new tests, so merge risk is minimal.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title states the main change: DAP string values are now shown as the debug adapter sends them. The raw summary confirms that formatValue() no longer strips quotes and that the change is in DebugAd…
Linked Issues check Passed Only #1992 is directly linked and active, so its display requirements apply. At the reviewed head, DebugAdapterVariableSupport.formatValue() returns Variable.getValue() unchanged, or an empty string w…
Out of Scope Changes check Passed All changes are in DebugAdapterVariableSupport (display of string values) and its new unit test. The change to the string presentation directly implements #1992. The removal of removeQuotes() has no o…
Description check Passed The description states the purpose (fix for #1992, string rendering in the Variables view), explains the problem with a before/after table, describes the change to formatValue() and removal of removeQ…
Full details: Title check

Explanation

The title states the main change: DAP string values are now shown as the debug adapter sends them. The raw summary confirms that formatValue() no longer strips quotes and that the change is in DebugAdapterVariableSupport. The title is specific, concise, and matches the changeset and the linked issue #1992.

Full details: Linked Issues check

Explanation

Only #1992 is directly linked and active, so its display requirements apply. At the reviewed head, DebugAdapterVariableSupport.formatValue() returns Variable.getValue() unchanged, or an empty string when null. It has no quote stripping and no removeQuotes() method. For type string, getValuePresentation() returns an XValuePresentation that calls renderer.renderValue(formattedValue, DefaultLanguageHighlighterColors.STRING). This shows the adapter text as sent, keeps the string color, and adds no quotes. Numeric, boolean and other types keep XNumericValuePresentation, XKeywordValuePresentation and XRegularValuePresentation with the same formatted value. DebugAdapterVariableSupportTest covers the #1992 strings (for example "'test'", "''test''", "'" and ""test""), the #812 strings 'name' and "'name'", a type String, and int, boolean and object values. The test file is present at the head. The test suite was not run in this review. The base-side diff could not be read, so the removal of the old code is confirmed only from the head content.

Full details: Out of Scope Changes check

Explanation

All changes are in DebugAdapterVariableSupport (display of string values) and its new unit test. The change to the string presentation directly implements #1992. The removal of removeQuotes() has no other caller, as the issue states. The string presentation no longer uses XStringValuePresentation. As a side effect, control-character marking and the 1,000-character cut-off in IntelliJ no longer apply to strings. The PR description states this side effect. It matches how other value types are already rendered, and it is part of the display path that #1992 asks to change. Set Value, evaluate results, watches and setExpression are not modified. No unrelated files were identified in the reviewed change summary.

Full details: Description check

Explanation

The description states the purpose (fix for #1992, string rendering in the Variables view), explains the problem with a before/after table, describes the change to formatValue() and removal of removeQuotes(), and lists the tests added. It is clearly related to the changeset.

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 4ef95346-b342-435b-b832-c8567a9a0b86
Commits

Reviewing files that changed from the base of the PR and between a043d48 and 54c1c30.

Files selected for processing: 2

  • src/main/java/com/redhat/devtools/lsp4ij/dap/descriptors/DebugAdapterVariableSupport.java
  • src/test/java/com/redhat/devtools/lsp4ij/dap/descriptors/DebugAdapterVariableSupportTest.java

Included review availability: This review used your included allowance. Your plan provides up to 2 included reviews per hour; 1 remain after this review.

@codecov

codecov Bot commented Nov 16, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 50.00000% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 49.00%. Comparing base (a043d48) to head (54c1c30).

Files with missing lines Patch % Lines
...j/dap/descriptors/DebugAdapterVariableSupport.java 50.00% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1994   +/-   ##
=======================================
  Coverage   48.99%   49.00%           
=======================================
  Files         812      812           
  Lines       32963    32958    -5     
  Branches     5096     5094    -2     
=======================================
  Hits        16150    16150           
  Misses      14271    14271           
+ Partials     2542     2537    -5     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@lagergren
lagergren merged commit 048cb4b into redhat-developer:main Nov 16, 2026
10 checks passed
lagergren added a commit that referenced this pull request Nov 16, 2026
…1995)

#1994 shows a string in the Variables view as the debug adapter sends it, with its quotes and escapes.
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.

DAP string rendering removes content quotes and corrupts escaped quote sequences

1 participant