Fix util.getStringWidth for falsy input (#3092)
parent
c0aaa0fa52
commit
1d3c86be4d
|
@ -740,6 +740,10 @@ function splitText(text) {
|
|||
}
|
||||
|
||||
function getStringWidth(text) {
|
||||
if (!text) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
// emojis are considered 2-char width for consistency
|
||||
// see https://github.com/sindresorhus/string-width/issues/11
|
||||
// for the reason why not implemented in `string-width`
|
||||
|
|
|
@ -33,6 +33,19 @@ exports[`emoji.md 1`] = `
|
|||
|
||||
`;
|
||||
|
||||
exports[`empty.md 1`] = `
|
||||
Foo | Bar
|
||||
--- | ---
|
||||
X |
|
||||
Y |
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
| Foo | Bar |
|
||||
| --- | --- |
|
||||
| X |
|
||||
| Y |
|
||||
|
||||
`;
|
||||
|
||||
exports[`escape.md 1`] = `
|
||||
| a | b | c |
|
||||
|:--|:-:|--:|
|
||||
|
|
|
@ -0,0 +1,4 @@
|
|||
Foo | Bar
|
||||
--- | ---
|
||||
X |
|
||||
Y |
|
|
@ -18,6 +18,7 @@ function run_spec(dirname, options, additionalParsers) {
|
|||
if (
|
||||
extname(filename) !== ".snap" &&
|
||||
fs.lstatSync(path).isFile() &&
|
||||
filename[0] !== "." &&
|
||||
filename !== "jsfmt.spec.js"
|
||||
) {
|
||||
let rangeStart = 0;
|
||||
|
|
Loading…
Reference in New Issue