SBoudrias/Inquirer.js — pull request #169 by tonylukasavage (2014-10-01 15:51:02+00:00)
Title: Fix multi-line error rendering for input type prompts (#167)

There was a relatively shallow, but present, rabbit-hole when addressing this issue. For ease of evaluation, I broke the commits associated with this PR into 3 distinct pieces, which I'll explain below.

#### fix rendering on multi-line errors (2976045)

This resolved the direct issue. It simply moves the cursor up based on the number of individual lines in the erorr message. Pretty simple.

#### prefix each error line with red >> (f110f1a)

When multi-line errors were printed, only the first line was prefixed with the red ">>" symbol. This commit prefixes each line in the resulting error message with that symbol for a more uniform output.

#### add errorHeight for appropriate next render (3368940)

This was the slightly tricky one. Once a multi-line error is rendered correctly, subsequent prompts, or the final result, would be rendered over it, rather than it being cleaned before moving on. For example, using the code in issue #167, the output might look something like this before this commit:

```
≫ node index.js
? name: test
{ name: 'test' }
>> error message that is going to
(~/development/inq)how inquirer.js
≫ re-renders the prompts.
```

With this commit I added the `this.errorHeight` property that keeps track of the height of the rendered error message, which will then be subsequently be used in the `Prompt.prototype.onEnd()` function to reposition and clear the message upon successful validation. This was the best, most lightweight way I could come up with to both solve the problem and keep the `error()` and `onEnd()` functions loosely coupled. Now it looks like this:

```
≫ node index.js
? name: test
{ name: 'test' }
```