AriaMinaei/pretty-error

How to turn of line wrapping

vjpr opened this issue · 7 comments

vjpr commented

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 commented

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.

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.

+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: 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 Thanks a lot

@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

jfmmm commented

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