Make line breaks in JSON strings visual only#3219
Open
laurakwhit wants to merge 2 commits intomainfrom
Open
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
| ); | ||
| }; | ||
|
|
||
| export const getLanguageExtension = (language: EditorLanguage) => |
Contributor
There was a problem hiding this comment.
⚠️ Property 'text' does not exist on type '{ json: LanguageSupport; java: LanguageSupport; go: LanguageSupport; php: LanguageSupport; python: StreamLanguage; shell: StreamLanguage<...>; dotnet: StreamLanguage<...>; ruby: StreamLanguage<...>; typescript: StreamLanguage<...>; }'.
Contributor
|
andrewzamojc
approved these changes
Mar 13, 2026
Contributor
andrewzamojc
left a comment
There was a problem hiding this comment.
Nice solution changing it to a br. Neat! LGTM 👍
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description & motivation 💭
getLineBreakExtensionwas usingEditorView.updateListenerto mutate the document by replaces every literal\nwith a real newline character. This was corrupting the JSON content and causingJSON.parseto fail validation.This PR uses a
ViewPluginwithMatchDecoratorandDecoration.replaceto visually render\nas a<br>line break. This means the underlying document content stays unchanged, sodoc.toString()still returns valid JSON with proper\nescape sequences. The visual line break only appears in read-only mode (wheneditableis false).Screenshots (if applicable) 📸
Design Considerations 🎨
Testing 🧪
How was this tested 👻
Steps for others to test: 🚶🏽♂️🚶🏽♀️
\\nin it (e.g. "Hello\nworld") with "json/plain" for "Encoding"\\nwas\\nin the valueChecklists
Draft Checklist
Merge Checklist
Issue(s) closed
DT-3659Docs
Any docs updates needed?