question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Line-wrapping bug

See original GitHub issue

Potentially related to #761

Expected Behavior

  • Code is not line-wrapped, OR
  • code is line-wrapped at 80 chars and preserves indentation, OR
  • control over line-wrapping (best behavior)

Actual Behavior

Line with <= 80 chars gets wrapped to newline, ignoring indentation

(Compare lines 5 and 6 in the output below to the input snippet)

Details

Output:

3cf10212-a156-4cde-9756-e245851c5b51

Input:

function html (tagName, attributes, ...childNodes) {
  const el = document.createElement(tagName);
  if (attributes) {
    for (const [prop, value] of Object.entries(attributes)) {
      if (prop === 'style' && (Array.isArray(value) || value instanceof Map)) {
        for (const declaration of value) {
          el.style.setProperty(...declaration);
        }
      }
      else {
        el.setAttribute(prop, value);
      }
    }
  }
  if (childNodes) {
    for (let node of childNodes) {
      if (typeof node === 'string') {
        node = document.createTextNode(node);
      }
      el.appendChild(node);
    }
  }
  return el;
}

Carbon config:

(Note: I removed the icon property)

{
  "paddingVertical": "0px",
  "paddingHorizontal": "0px",
  "marginVertical": "45px",
  "marginHorizontal": "45px",
  "backgroundImage": null,
  "backgroundImageSelection": null,
  "backgroundMode": "color",
  "backgroundColor": "rgba(171, 184, 195, 1)",
  "dropShadow": false,
  "dropShadowOffsetY": "20px",
  "dropShadowBlurRadius": "68px",
  "theme": "one-dark",
  "windowTheme": "sharp",
  "language": "javascript",
  "fontFamily": "Hack",
  "fontSize": "14px",
  "lineHeight": "133%",
  "windowControls": false,
  "widthAdjustment": false,
  "lineNumbers": true,
  "exportSize": "2x",
  "watermark": false,
  "squaredImage": false,
  "loading": false,
  "isVisible": true,
  "custom": true
}
Browser: Win 10, Chrome 75.0.3770.80

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:15 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
onelsoncommented, Sep 30, 2019

Noticing an incorrect linewrap of my own on Chrome 77.0.3865.90 (linux) with:

// Big Step Operational Semantics

impl Expression for Add {
    fn evaluate(&self, environment: &Environment) -> Expr {
        match (
            self.0.evaluate(environment).as_value(),
            self.1.evaluate(environment).as_value(),
        ) {
            (Some(Value::Number(a)), Some(Value::Number(b))) => Value::Number(a + b).into(),
            _ => panic!("Unexpected values"),
        }
    }
}

png rendered output

Seems like there should be a linebreak before the _ => panic!("Unexpected values"), instead of just following on as a continuation.

1reaction
oliversturmcommented, Sep 11, 2019

I have no idea at this time what the cause of the issue is. If I had to guess I would say that some kind of width calculation is very slightly off, so it renders incorrect results when certain combinations of fonts, font sizes and rendering engines are used.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Line wrapping visual issue (eats itself from behind) #2713
-After wrapping around once, and eating itself up completely, the line correctly hits the right edge of the window and wraps around, changing ......
Read more >
[Bug] Microsoft Word Wrapping & Paragraph
Mainly problems is that the image wraps and the paragraph is often messed up when i opening my assignment from Microsoft Word Mobile....
Read more >
Fixing My Line Wrap Issue in iTerm 2 - Tim Dunklee
The problem was that when text was supposed to wrap to a new line (e.g. writing a long commit message) it would instead...
Read more >
[KNOWN BUG] Text wrapping not working in lines (Has ...
Description: When adding text to lines, the text wrapping does not function properly. It goes over the edge and extends past where the...
Read more >
textwrap — Text wrapping and filling — Python 3.11.1 ...
Wraps the single paragraph in text (a string) so every line is at most width characters long. Returns a list of output lines,...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found