Repository navigation
feat: toggle word wrap on code snippets - #556
Merged
anoopcodehack merged 1 commit intoSep 27, 2026
Merged
Conversation
Closes anoopcodehack#525. The snippet viewer rendered SyntaxHighlighter without wrapLongLines, so a long line could only be reached by scrolling sideways inside a card that is already narrow. A Wrap button next to Copy now switches between the two. The setting lives per viewer rather than globally: one card can hold a wide table that reads better wrapped, while another holds code whose shape is the point and where wrapping would hide it. The button carries aria-pressed so its state is not colour-only, and its title says what a click will do rather than what the state is.
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.
Closes #525.
The snippet viewer rendered
SyntaxHighlighterwithoutwrapLongLines, so a long line could only be reached by scrolling sideways inside a card that is already narrow. A Wrap button next to Copy now switches between the two.What changed
Three small edits in
TaskCard.jsx:wrapLinesstate next toselectedSnippetwrapLongLines={wrapLines}on the highlighterTwo decisions worth naming
The setting is per viewer, not global. One card can hold a wide table that reads better wrapped, while another holds code whose shape is the point and where wrapping would hide it. Keeping it on the card means each one can be what it needs to be, and nothing has to be remembered across the board.
The button is not colour-only. It carries
aria-pressed, and itstitlesays what a click will do ("Long lines wrap; click to scroll instead") rather than what the state currently is, which is the part that is ambiguous when you are looking at a toggle for the first time.Test plan
npm run buildpasses (the chunk-size warning is pre-existing and unrelated).There is no test setup in the client, so the behaviour itself I verified by reading the installed
react-syntax-highlighter15.6.6:wrapLongLinesputswhiteSpace: 'pre-wrap'on thecodeelement's style, while the existingcustomStylehere goes on thepreelement. The two do not collide, so the prop takes effect as it should with this viewer's styling.