Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Address code wrapping visual issue when both wrapLongLines and showLineNumbers are set to true #483

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

rdai10
Copy link

@rdai10 rdai10 commented Sep 21, 2022

This pr is in response to #376 where when both wrapLongLines and showLineNumbers are set to true, the UI sometimes breaks. This issue is more prominent the smaller the viewport is.

It does the following:

  1. Adds word-break: break-word; along side white-space: pre-wrap; to address the horizontal scroll bar introduced by a long path (as mentioned on Code wrapping breaks when wrapLongLines and showLineNumbers are set #376 (comment))
    Before:
    image
    After:
    image

  2. It addresses the code misalignment introduced by display:flex; on the parent span by nesting the code one layer deeper.
    image

Please see a screencast of the comparisons below:
Before:

syntax-highlighter-before.mov

After:

syntax-highlighter-after.mov

Any feedback welcome, thanks!

…re both on

- When both the wrapLongLines and showLineNumbers props are turned on, if the code text is long enough to wrap, the `display: flex` on the wrapping span forces all its children to be equal height. Nesting the children one layer deep ensures that the line number aligns with the rest of the code in that line nicer.
@codecov
Copy link

codecov bot commented Sep 21, 2022

Codecov Report

Merging #483 (edb70c2) into master (6990564) will decrease coverage by 0.86%.
The diff coverage is 16.66%.

@@            Coverage Diff             @@
##           master     #483      +/-   ##
==========================================
- Coverage   95.97%   95.10%   -0.87%     
==========================================
  Files          11       11              
  Lines         323      327       +4     
  Branches      123      125       +2     
==========================================
+ Hits          310      311       +1     
- Misses         12       14       +2     
- Partials        1        2       +1     
Impacted Files Coverage Δ
src/highlight.js 93.52% <16.66%> (-1.66%) ⬇️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

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.

None yet

1 participant