diff --git a/bench.esy.lock/index.json b/bench.esy.lock/index.json index 63bbfb368..a5873100a 100644 --- a/bench.esy.lock/index.json +++ b/bench.esy.lock/index.json @@ -414,8 +414,8 @@ ], "devDependencies": [ "ocaml@4.7.1004@d41d8cd9" ] }, - "@opam/tyxml@opam:4.3.0@b35a7c40": { - "id": "@opam/tyxml@opam:4.3.0@b35a7c40", + "@opam/tyxml@opam:4.3.0@15e44054": { + "id": "@opam/tyxml@opam:4.3.0@15e44054", "name": "@opam/tyxml", "version": "opam:4.3.0", "source": { @@ -579,7 +579,7 @@ }, "overrides": [], "dependencies": [ - "ocaml@4.7.1004@d41d8cd9", "@opam/tyxml@opam:4.3.0@b35a7c40", + "ocaml@4.7.1004@d41d8cd9", "@opam/tyxml@opam:4.3.0@15e44054", "@opam/dune@opam:1.7.3@72aad784", "@opam/base-bytes@opam:base@19d0c2ff", "@esy-ocaml/substs@0.0.1@d41d8cd9" @@ -657,7 +657,7 @@ }, "overrides": [], "dependencies": [ - "ocaml@4.7.1004@d41d8cd9", "@opam/tyxml@opam:4.3.0@b35a7c40", + "ocaml@4.7.1004@d41d8cd9", "@opam/tyxml@opam:4.3.0@15e44054", "@opam/result@opam:1.3@bee8bf2e", "@opam/fpath@opam:0.7.2@45477b93", "@opam/dune@opam:1.7.3@72aad784", "@opam/cppo@opam:1.6.5@bec3dbd9", "@opam/cmdliner@opam:1.0.2@8ab0598a", @@ -772,8 +772,8 @@ ], "devDependencies": [ "ocaml@4.7.1004@d41d8cd9" ] }, - "@opam/merlin-extend@opam:0.3@e1fc0d08": { - "id": "@opam/merlin-extend@opam:0.3@e1fc0d08", + "@opam/merlin-extend@opam:0.3@0af73a50": { + "id": "@opam/merlin-extend@opam:0.3@0af73a50", "name": "@opam/merlin-extend", "version": "opam:0.3", "source": { @@ -1568,7 +1568,7 @@ "ocaml@4.7.1004@d41d8cd9", "@opam/result@opam:1.3@bee8bf2e", "@opam/ocamlfind@opam:1.8.0@f744a0c5", "@opam/ocaml-migrate-parsetree@opam:1.2.0@23e55f71", - "@opam/merlin-extend@opam:0.3@e1fc0d08", + "@opam/merlin-extend@opam:0.3@0af73a50", "@opam/menhir@opam:20181113@0c8257a8", "@opam/dune@opam:1.7.3@72aad784" ], diff --git a/bench.esy.lock/opam/merlin-extend.0.3/opam b/bench.esy.lock/opam/merlin-extend.0.3/opam index db2b130a4..03ed72e73 100644 --- a/bench.esy.lock/opam/merlin-extend.0.3/opam +++ b/bench.esy.lock/opam/merlin-extend.0.3/opam @@ -9,7 +9,7 @@ build: [make] install: [make "install"] remove: ["ocamlfind" "remove" "merlin_extend"] depends: [ - "ocaml" {>= "4.02.3"} + "ocaml" {>= "4.02.3" & < "4.08.0"} "ocamlfind" {build} "cppo" {build} ] diff --git a/bench.esy.lock/opam/tyxml.4.3.0/opam b/bench.esy.lock/opam/tyxml.4.3.0/opam index 1333f05f9..aeac6c9ba 100644 --- a/bench.esy.lock/opam/tyxml.4.3.0/opam +++ b/bench.esy.lock/opam/tyxml.4.3.0/opam @@ -14,11 +14,12 @@ build: [ depends: [ "ocaml" {>= "4.02"} + "re" {>= "1.5.0"} + ("ocaml" {>= "4.07"} | "re" {>= "1.8.0"}) "dune" {build} "alcotest" {with-test} "seq" "uutf" {>= "1.0.0"} - "re" {>= "1.5.0"} ] synopsis:"TyXML is a library for building correct HTML and SVG documents" diff --git a/bench.esy.lock/overrides/opam__s__merlin_extend_opam__c__0.3_opam_override/files/merlin-extend-winfix-4.2.3007.patch b/bench.esy.lock/overrides/opam__s__merlin_extend_opam__c__0.3_opam_override/files/merlin-extend-winfix-4.2.3007.patch new file mode 100644 index 000000000..1e59ebb36 --- /dev/null +++ b/bench.esy.lock/overrides/opam__s__merlin_extend_opam__c__0.3_opam_override/files/merlin-extend-winfix-4.2.3007.patch @@ -0,0 +1,34 @@ +--- ./extend_helper.ml ++++ ./extend_helper.ml +@@ -1,13 +1,6 @@ +-(*pp cppo -V OCAML:`ocamlc -version` *) + open Parsetree + open Extend_protocol + +-#if OCAML_VERSION < (4, 3, 0) +-# define CONST_STRING Asttypes.Const_string +-#else +-# define CONST_STRING Parsetree.Pconst_string +-#endif +- + (** Default implementation for [Reader_def.print_outcome] using + [Oprint] from compiler-libs *) + let print_outcome_using_oprint ppf = function +@@ -28,7 +21,7 @@ + pstr_loc = Location.none; + pstr_desc = Pstr_eval ({ + pexp_loc = Location.none; +- pexp_desc = Pexp_constant (CONST_STRING (msg, None)); ++ pexp_desc = Pexp_constant (Asttypes.Const_string (msg, None)); + pexp_attributes = []; + }, []); + }] +@@ -112,7 +105,7 @@ + let msg = match payload with + | PStr [{ + pstr_desc = Pstr_eval ({ +- pexp_desc = Pexp_constant (CONST_STRING (msg, _)); ++ pexp_desc = Pexp_constant (Asttypes.Const_string (msg, _)); + }, _); + }] -> msg + | _ -> "Warning: extension produced an incorrect syntax-error node" diff --git a/bench.esy.lock/overrides/opam__s__merlin_extend_opam__c__0.3_opam_override/package.json b/bench.esy.lock/overrides/opam__s__merlin_extend_opam__c__0.3_opam_override/package.json index 1675df21a..acc90eb32 100644 --- a/bench.esy.lock/overrides/opam__s__merlin_extend_opam__c__0.3_opam_override/package.json +++ b/bench.esy.lock/overrides/opam__s__merlin_extend_opam__c__0.3_opam_override/package.json @@ -1,9 +1,12 @@ { + "buildEnv": { + "PATCH_CMD": "#{ocaml.version == '4.2.3007' ? 'patch -p1 < merlin-extend-winfix-4.2.3007.patch' : 'patch -p1 < merlin-extend-winfix.patch'}" + }, "build": [ [ "bash", "-c", - "#{os == 'windows' ? 'patch -p1 < merlin-extend-winfix.patch' : 'true'}" + "#{os == 'windows' ? $PATCH_CMD : 'true'}" ], [ "make" diff --git a/esy.lock/index.json b/esy.lock/index.json index 8f17b542a..70db42357 100644 --- a/esy.lock/index.json +++ b/esy.lock/index.json @@ -414,8 +414,8 @@ ], "devDependencies": [ "ocaml@4.7.1004@d41d8cd9" ] }, - "@opam/tyxml@opam:4.3.0@b35a7c40": { - "id": "@opam/tyxml@opam:4.3.0@b35a7c40", + "@opam/tyxml@opam:4.3.0@15e44054": { + "id": "@opam/tyxml@opam:4.3.0@15e44054", "name": "@opam/tyxml", "version": "opam:4.3.0", "source": { @@ -579,7 +579,7 @@ }, "overrides": [], "dependencies": [ - "ocaml@4.7.1004@d41d8cd9", "@opam/tyxml@opam:4.3.0@b35a7c40", + "ocaml@4.7.1004@d41d8cd9", "@opam/tyxml@opam:4.3.0@15e44054", "@opam/dune@opam:1.7.3@72aad784", "@opam/base-bytes@opam:base@19d0c2ff", "@esy-ocaml/substs@0.0.1@d41d8cd9" @@ -657,7 +657,7 @@ }, "overrides": [], "dependencies": [ - "ocaml@4.7.1004@d41d8cd9", "@opam/tyxml@opam:4.3.0@b35a7c40", + "ocaml@4.7.1004@d41d8cd9", "@opam/tyxml@opam:4.3.0@15e44054", "@opam/result@opam:1.3@bee8bf2e", "@opam/fpath@opam:0.7.2@45477b93", "@opam/dune@opam:1.7.3@72aad784", "@opam/cppo@opam:1.6.5@bec3dbd9", "@opam/cmdliner@opam:1.0.2@8ab0598a", @@ -772,8 +772,8 @@ ], "devDependencies": [ "ocaml@4.7.1004@d41d8cd9" ] }, - "@opam/merlin-extend@opam:0.3@e1fc0d08": { - "id": "@opam/merlin-extend@opam:0.3@e1fc0d08", + "@opam/merlin-extend@opam:0.3@0af73a50": { + "id": "@opam/merlin-extend@opam:0.3@0af73a50", "name": "@opam/merlin-extend", "version": "opam:0.3", "source": { @@ -1568,7 +1568,7 @@ "ocaml@4.7.1004@d41d8cd9", "@opam/result@opam:1.3@bee8bf2e", "@opam/ocamlfind@opam:1.8.0@f744a0c5", "@opam/ocaml-migrate-parsetree@opam:1.2.0@23e55f71", - "@opam/merlin-extend@opam:0.3@e1fc0d08", + "@opam/merlin-extend@opam:0.3@0af73a50", "@opam/menhir@opam:20181113@0c8257a8", "@opam/dune@opam:1.7.3@72aad784" ], diff --git a/esy.lock/opam/merlin-extend.0.3/opam b/esy.lock/opam/merlin-extend.0.3/opam index db2b130a4..03ed72e73 100644 --- a/esy.lock/opam/merlin-extend.0.3/opam +++ b/esy.lock/opam/merlin-extend.0.3/opam @@ -9,7 +9,7 @@ build: [make] install: [make "install"] remove: ["ocamlfind" "remove" "merlin_extend"] depends: [ - "ocaml" {>= "4.02.3"} + "ocaml" {>= "4.02.3" & < "4.08.0"} "ocamlfind" {build} "cppo" {build} ] diff --git a/esy.lock/opam/tyxml.4.3.0/opam b/esy.lock/opam/tyxml.4.3.0/opam index 1333f05f9..aeac6c9ba 100644 --- a/esy.lock/opam/tyxml.4.3.0/opam +++ b/esy.lock/opam/tyxml.4.3.0/opam @@ -14,11 +14,12 @@ build: [ depends: [ "ocaml" {>= "4.02"} + "re" {>= "1.5.0"} + ("ocaml" {>= "4.07"} | "re" {>= "1.8.0"}) "dune" {build} "alcotest" {with-test} "seq" "uutf" {>= "1.0.0"} - "re" {>= "1.5.0"} ] synopsis:"TyXML is a library for building correct HTML and SVG documents" diff --git a/esy.lock/overrides/opam__s__merlin_extend_opam__c__0.3_opam_override/files/merlin-extend-winfix-4.2.3007.patch b/esy.lock/overrides/opam__s__merlin_extend_opam__c__0.3_opam_override/files/merlin-extend-winfix-4.2.3007.patch new file mode 100644 index 000000000..1e59ebb36 --- /dev/null +++ b/esy.lock/overrides/opam__s__merlin_extend_opam__c__0.3_opam_override/files/merlin-extend-winfix-4.2.3007.patch @@ -0,0 +1,34 @@ +--- ./extend_helper.ml ++++ ./extend_helper.ml +@@ -1,13 +1,6 @@ +-(*pp cppo -V OCAML:`ocamlc -version` *) + open Parsetree + open Extend_protocol + +-#if OCAML_VERSION < (4, 3, 0) +-# define CONST_STRING Asttypes.Const_string +-#else +-# define CONST_STRING Parsetree.Pconst_string +-#endif +- + (** Default implementation for [Reader_def.print_outcome] using + [Oprint] from compiler-libs *) + let print_outcome_using_oprint ppf = function +@@ -28,7 +21,7 @@ + pstr_loc = Location.none; + pstr_desc = Pstr_eval ({ + pexp_loc = Location.none; +- pexp_desc = Pexp_constant (CONST_STRING (msg, None)); ++ pexp_desc = Pexp_constant (Asttypes.Const_string (msg, None)); + pexp_attributes = []; + }, []); + }] +@@ -112,7 +105,7 @@ + let msg = match payload with + | PStr [{ + pstr_desc = Pstr_eval ({ +- pexp_desc = Pexp_constant (CONST_STRING (msg, _)); ++ pexp_desc = Pexp_constant (Asttypes.Const_string (msg, _)); + }, _); + }] -> msg + | _ -> "Warning: extension produced an incorrect syntax-error node" diff --git a/esy.lock/overrides/opam__s__merlin_extend_opam__c__0.3_opam_override/package.json b/esy.lock/overrides/opam__s__merlin_extend_opam__c__0.3_opam_override/package.json index 1675df21a..acc90eb32 100644 --- a/esy.lock/overrides/opam__s__merlin_extend_opam__c__0.3_opam_override/package.json +++ b/esy.lock/overrides/opam__s__merlin_extend_opam__c__0.3_opam_override/package.json @@ -1,9 +1,12 @@ { + "buildEnv": { + "PATCH_CMD": "#{ocaml.version == '4.2.3007' ? 'patch -p1 < merlin-extend-winfix-4.2.3007.patch' : 'patch -p1 < merlin-extend-winfix.patch'}" + }, "build": [ [ "bash", "-c", - "#{os == 'windows' ? 'patch -p1 < merlin-extend-winfix.patch' : 'true'}" + "#{os == 'windows' ? $PATCH_CMD : 'true'}" ], [ "make" diff --git a/src/Core/TextWrapping.re b/src/Core/TextWrapping.re index fdbec0247..8fc3cdfd5 100644 --- a/src/Core/TextWrapping.re +++ b/src/Core/TextWrapping.re @@ -61,13 +61,17 @@ let wrapText = (~text, ~measureWidth, ~maxWidth, ~wrapHere) => { if (width >= maxWidth) { let (line, lineWidth) = subAndMeasure(acc.beginIndex, acc.endIndex); - let (lastLine, lastLineWidth) = - subAndMeasure(acc.endIndex + 2, index); + if (acc.endIndex + 2 > index) { + {...acc, lines: [line, ...acc.lines], currMaxWidth: lineWidth}; + } else { + let (lastLine, lastLineWidth) = + subAndMeasure(acc.endIndex + 2, index); - let currMaxWidth = - max(lastLineWidth, max(acc.currMaxWidth, lineWidth)); + let currMaxWidth = + max(lastLineWidth, max(acc.currMaxWidth, lineWidth)); - {...acc, lines: [lastLine, line, ...acc.lines], currMaxWidth}; + {...acc, lines: [lastLine, line, ...acc.lines], currMaxWidth}; + }; } else { let (line, lineWidth) = subAndMeasure(acc.beginIndex, index); diff --git a/test/Core/TextWrappingTests.re b/test/Core/TextWrappingTests.re new file mode 100644 index 000000000..1597043cf --- /dev/null +++ b/test/Core/TextWrappingTests.re @@ -0,0 +1,16 @@ +open Rejest; + +open Revery_Core; + +test("TextWrapping", () => + test("doesn't crash when supplied with text that is too wide", () => { + let measureWidth = _ => 14; + let wrapHere = TextWrapping.isWhitespaceWrapPoint; + let text = "W"; + let maxWidth = 12; + let (text, width) = + TextWrapping.wrapText(~text, ~measureWidth, ~maxWidth, ~wrapHere); + expect(text).toEqual(["W"]); + expect(width).toEqual(14); + }) +);