From 592b4d1743a7fb3708c940b079a5913ba6df788d Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Mon, 20 Jun 2016 11:24:14 +0200 Subject: [PATCH] [hardwrap addon] Fix corner case for words whose length equals the wrap column Issue #4069 --- addon/wrap/hardwrap.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/addon/wrap/hardwrap.js b/addon/wrap/hardwrap.js index 8806fbe2f2..04851f99ff 100644 --- a/addon/wrap/hardwrap.js +++ b/addon/wrap/hardwrap.js @@ -30,7 +30,9 @@ } function findBreakPoint(text, column, wrapOn, killTrailingSpace) { - for (var at = column; at > 0; --at) + var at = column + while (at < text.length && text.charAt(at) == " ") at++ + for (; at > 0; --at) if (wrapOn.test(text.slice(at - 1, at + 1))) break; for (var first = true;; first = false) { var endOfText = at;