ruby / ruby/irb

Make `literal_type` indicator detect more open chunks of code, not only strings

Open
#98 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Ruby
Stars
478
Forks
158
Avg merge
1d 12h
Merged PRs (30d)
12

Description

Description

Literal type (or @ltype) is this character in the end of prompt:

          ↓
2.6.3 :001 > 'closed string'
2.6.3 :002"> %Q[not closed array of words
2.6.3 :003/> /not closed regexp
2.6.3 :004`> `echo open backtick
          ↑

Documentation says that it detects string types:

#     %l    # type of string(", ', /, ]), `]' is inner %w[...]

But it already does more than that, detecting regular expressions and some array types:

2.6.3 :003/> /not closed regexp
# Array of words
2.6.3 :003]> %w[word word

So I think it would be convenient if it detected open parentheses, square and curly braces as well. For example:

2.6.3 :003)> parentheses = (a + b * c
2.6.3 :003]> array = [1, 'milk'

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by locating the literal_type/@ltype implementation and any tests covering its current string, regexp, and array detection. Extend the behavior to recognize open parentheses, square brackets, and curly braces, then verify that the prompt indicator reports each example as open.

Written by the indexing model from the issue text.

Assessment

Tech stack
ruby
Domain
cli
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.