pretty-error icon indicating copy to clipboard operation
pretty-error copied to clipboard

How to turn of line wrapping

Open vjpr opened this issue 10 years ago • 7 comments

I couldn't figure out a way to turn of line wrapping.

In CSS it would be white-space: nowrap, but its seems in RenderKid you are setting a terminal width.

My use case is that I am rendering urls which need to be clickable (using CMD + double-click on OSX). For this reason I cannot have line breaks in between urls.

vjpr avatar Jul 22 '15 03:07 vjpr

For a start it would be good to be able to pass config to RenderKid - https://github.com/AriaMinaei/pretty-error/blob/master/src/pretty-error.coffee#L39.

EDIT: This did not work. Looks like in Layout there is a config property called width that is set to 80, but cannot be configured anywhere.

vjpr avatar Jul 22 '15 03:07 vjpr

Hey @vjpr, thanks for the suggestion. Since it's been a while since you opened this issue (sry for that), I'll wait to see if you still need it fixed. So, let me know.

AriaMinaei avatar Aug 16 '15 19:08 AriaMinaei

+1 for supporting an option to turn off line wrapping.

It displays weird when the error message has too many words.

e.g.

var PrettyError = require('pretty-error');
var pe = new PrettyError();
var renderedError = pe.render(new Error('this is a looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong message'));
console.log(renderedError);

it shows that:

image

adoyle-h avatar Dec 20 '15 11:12 adoyle-h

@adoyle-h: This was a bug in RenderKid, where it couldn't correctly query the terminal's width, so it would just guess '80'. I've pushed a fix which will land in RenderKid 2.0, and pretty-error 2.0.

AriaMinaei avatar Dec 22 '15 11:12 AriaMinaei

@AriaMinaei Thanks a lot

adoyle-h avatar Dec 22 '15 12:12 adoyle-h

@AriaMinaei This does work, however I have to react into the object to set it. Would be cool if PrettyError constructor took an options hash.

pe._renderer._config.terminalWidth = 9999

jonjaques avatar Aug 03 '16 17:08 jonjaques

Another problem is that trying to add color with chalk to an error message will break the terminalWidth.

jfmmm avatar Aug 29 '18 15:08 jfmmm