diff --git a/src/doc/doc-printer.js b/src/doc/doc-printer.js index 72e2be2fe..0ed9b0f8d 100644 --- a/src/doc/doc-printer.js +++ b/src/doc/doc-printer.js @@ -476,14 +476,14 @@ function printDocToString(doc, options) { while ( out.length > 0 && typeof out[out.length - 1] === "string" && - out[out.length - 1].match(/^[^\S\n]*$/) + out[out.length - 1].match(/^[ \t]*$/) ) { out.pop(); } if (out.length && typeof out[out.length - 1] === "string") { out[out.length - 1] = out[out.length - 1].replace( - /[^\S\n]*$/, + /[ \t]*$/, "" ); } diff --git a/tests/jsx-whitespace/__snapshots__/jsfmt.spec.js.snap b/tests/jsx-whitespace/__snapshots__/jsfmt.spec.js.snap index 9044b3c1f..612e31555 100644 --- a/tests/jsx-whitespace/__snapshots__/jsfmt.spec.js.snap +++ b/tests/jsx-whitespace/__snapshots__/jsfmt.spec.js.snap @@ -23,6 +23,12 @@ non_breaking_spaces =
]   [
em_space =
]   [
hair_space =
]  [
zero_width_space =
]​​​[
+real_world_non_breaking_spaces =

+ Supprimer l’objectif « {goal.name} » ? +

+real_world_non_breaking_spaces2 =

+ Supprimer l’objectif padding padding padding padding padding padding « {goal.name} » ? +

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // Treated as whitespace in JSX spaces =
] [
; @@ -39,5 +45,12 @@ non_breaking_spaces =
]   [
; em_space =
]   [
; hair_space =
]  [
; zero_width_space =
]​​​[
; +real_world_non_breaking_spaces =

Supprimer l’objectif « {goal.name} » ?

; +real_world_non_breaking_spaces2 = ( +

+ Supprimer l’objectif padding padding padding padding padding padding «  + {goal.name} » ? +

+); `; diff --git a/tests/jsx-whitespace/test.js b/tests/jsx-whitespace/test.js index 22d128522..fa92e9d44 100644 --- a/tests/jsx-whitespace/test.js +++ b/tests/jsx-whitespace/test.js @@ -20,3 +20,9 @@ non_breaking_spaces =
]   [
em_space =
]   [
hair_space =
]  [
zero_width_space =
]​​​[
+real_world_non_breaking_spaces =

+ Supprimer l’objectif « {goal.name} » ? +

+real_world_non_breaking_spaces2 =

+ Supprimer l’objectif padding padding padding padding padding padding « {goal.name} » ? +

diff --git a/tests/unicode/__snapshots__/jsfmt.spec.js.snap b/tests/unicode/__snapshots__/jsfmt.spec.js.snap index 560b20e19..aff1d8160 100644 --- a/tests/unicode/__snapshots__/jsfmt.spec.js.snap +++ b/tests/unicode/__snapshots__/jsfmt.spec.js.snap @@ -17,3 +17,16 @@ exports[`keys.js - flow-verify 1`] = ` ({ この事はつもり素晴らしいことさ: "35jL9V" }); `; + +exports[`nbsp-jsx.js - flow-verify 1`] = ` +// Note: there are non breaking spaces in the JSX text +x =

 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa 

; +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +// Note: there are non breaking spaces in the JSX text +x = ( +

+  aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa  +

+); + +`; diff --git a/tests/unicode/nbsp-jsx.js b/tests/unicode/nbsp-jsx.js new file mode 100644 index 000000000..a5c349b99 --- /dev/null +++ b/tests/unicode/nbsp-jsx.js @@ -0,0 +1,2 @@ +// Note: there are non breaking spaces in the JSX text +x =

 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa 

;