This is an automated email from the ASF dual-hosted git repository.
rubys pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/whimsy.git
The following commit(s) were added to refs/heads/master by this push:
new 5aaf96c treat lines with no spaces after column 40 as non-reflowable
5aaf96c is described below
commit 5aaf96cb2619647dadb5fbbd33ce8f8723ae52fa
Author: Sam Ruby <[email protected]>
AuthorDate: Mon Apr 22 09:48:37 2019 -0400
treat lines with no spaces after column 40 as non-reflowable
---
www/board/agenda/spec/reflow_spec.rb | 18 ++++++++++++++++++
www/board/agenda/views/utils.js.rb | 16 ++++++++++------
2 files changed, 28 insertions(+), 6 deletions(-)
diff --git a/www/board/agenda/spec/reflow_spec.rb
b/www/board/agenda/spec/reflow_spec.rb
index 56199ec..d494d47 100644
--- a/www/board/agenda/spec/reflow_spec.rb
+++ b/www/board/agenda/spec/reflow_spec.rb
@@ -37,5 +37,23 @@ describe "reflow", type: :feature, server: :vue do
expect(page.body).to eq "a?\nb:\nc"
end
+
+ it "leaves long URLs alone" do
+ @line = "[7] http://example.com" + "/foobar" * 12
+
+ on_vue_server do
+ line = @line
+
+ class TestReflow < Vue
+ def render
+ _ Flow.text(line)
+ end
+ end
+
+ Vue.renderResponse(TestReflow, response)
+ end
+
+ expect(page.body).to eq @line
+ end
end
end
diff --git a/www/board/agenda/views/utils.js.rb
b/www/board/agenda/views/utils.js.rb
index 0e5f503..cc90386 100644
--- a/www/board/agenda/views/utils.js.rb
+++ b/www/board/agenda/views/utils.js.rb
@@ -188,12 +188,16 @@ class Flow
gsub(/(.{1,#{len}})( +|$\n?)/, "$1\n").
sub(/[\n\r]+$/, '')
else
- # preserve indentation.
- n = len - prefix.length;
- indent = prefix.gsub(/\S/, ' ')
- lines[i] = prefix + line[prefix.length..-1].
- gsub(/(.{1,#{n}})( +|$\n?)/, indent + "$1\n").
- sub(indent, '').sub(/[\n\r]+$/, '')
+ # ensure line can be split after column 40
+ lastspace = /^.*\s\S/.exec(line)
+ if lastspace and lastspace[0].length - 1 > 40
+ # preserve indentation.
+ n = len - prefix.length;
+ indent = prefix.gsub(/\S/, ' ')
+ lines[i] = prefix + line[prefix.length..-1].
+ gsub(/(.{1,#{n}})( +|$\n?)/, indent + "$1\n").
+ sub(indent, '').sub(/[\n\r]+$/, '')
+ end
end
end