summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorNobuyoshi Nakada <nobu@ruby-lang.org>2021-10-11 20:34:55 +0900
committergit <svn-admin@ruby-lang.org>2021-10-12 00:40:22 +0900
commit60689f0f20cf54ea85aea6ec7e07e3b8bb7c7119 (patch)
tree245d19c878cc27bd7a7a459dea4b329f9ba1da33 /lib
parente212d051d0358734f78b5c402dddd9b631a12fe1 (diff)
[ruby/reline] Fix zero division when the screen width is not available
https://github.com/ruby/reline/commit/0dce9da083
Diffstat (limited to 'lib')
-rw-r--r--lib/reline/line_editor.rb3
1 files changed, 2 insertions, 1 deletions
diff --git a/lib/reline/line_editor.rb b/lib/reline/line_editor.rb
index f6facc9da8..c1bb49033a 100644
--- a/lib/reline/line_editor.rb
+++ b/lib/reline/line_editor.rb
@@ -340,7 +340,8 @@ class Reline::LineEditor
end
private def calculate_height_by_width(width)
- width.div(@screen_size.last) + 1
+ max_width = @screen_size.last
+ max_width > 0 ? (width.div(max_width) + 1) : 1
end
private def split_by_width(str, max_width)