Skip to content

"index out of string" error in Strings.wrap #16

@jscheid

Description

@jscheid

Describe the problem

Strings.wrap throws an IndexError.

Steps to reproduce the problem

Strings.wrap(
  "zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz   \e[1m\e[35m zzzzzzz\e[0m  \e[1m\e[35mzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz",
  62
)

Actual behaviour

         [snip]
	 8: from /usr/local/bundle/gems/strings-0.2.1/lib/strings.rb:109:in `wrap'
	 7: from /usr/local/bundle/gems/strings-0.2.1/lib/strings/wrap.rb:29:in `wrap'
	 6: from /usr/local/bundle/gems/strings-0.2.1/lib/strings/wrap.rb:29:in `map'
	 5: from /usr/local/bundle/gems/strings-0.2.1/lib/strings/wrap.rb:30:in `block in wrap'
	 4: from /usr/local/bundle/gems/strings-0.2.1/lib/strings/wrap.rb:111:in `format_line'
	 3: from /usr/local/bundle/gems/strings-0.2.1/lib/strings/wrap.rb:142:in `insert_ansi'
	 2: from /usr/local/bundle/gems/strings-0.2.1/lib/strings/wrap.rb:142:in `reverse_each'
	 1: from /usr/local/bundle/gems/strings-0.2.1/lib/strings/wrap.rb:158:in `block in insert_ansi'
/usr/local/bundle/gems/strings-0.2.1/lib/strings/wrap.rb:158:in `insert': index 56 out of string (IndexError)

Expected behaviour

What did you expect to happen?

Describe your environment

  • OS version: Debian 10.9
  • Ruby version: ruby 2.6.6p146 (2020-03-31 revision 67876) [x86_64-linux]
  • Strings version: 0.2.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions