Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

allow space in config value #705

Merged
merged 5 commits into from
May 26, 2024
Merged

allow space in config value #705

merged 5 commits into from
May 26, 2024

Conversation

monkeyWzr
Copy link
Contributor

@monkeyWzr monkeyWzr commented May 15, 2024

Fix #657 .

(By the way, please forgive me for using the master branch. I know that is bad practice🙇‍♂️)

@@ -388,7 +388,8 @@ def test_additional_key_bindings_for_other_keymap
"cd": "CD"
set keymap emacs
"ef": "EF"
set editing-mode vi # keymap changes to be vi-insert
# keymap changes to be vi-insert
set editing-mode vi
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Although inline comment does not exist, we should support ignore-after-space feature because readline behave like inline comment exists and it is actually used.

# ignore after space
"\C-f": history-search-forward ignored-string
set editing-mode vi ignored-string

# do not ignore after space
set emacs-mode-string emacs mode string

I think it is better to leave the test as is.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Got it! Trimmed the comment before handling the line.

@@ -182,7 +182,7 @@ def read_lines(lines, file = nil)
next if if_stack.any? { |_no, skip| skip }

case line
when /^set +([^ ]+) +([^ ]+)/i
when /^set +([^ ]+) +(.+)/i
var, value = $1.downcase, $2
bind_variable(var, value)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For an example input set foo bar baz, how about passing three values to bind_variable?

var = 'foo'
value = 'bar'
raw_value = 'bar baz'
bind_variable(var, value, raw_value)

Most variable still uses value, and some variables (that uses retrieve_string(value) now) will use retrieve_string(raw_value)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! Added raw_value as a third argument to bind_variable()

@monkeyWzr monkeyWzr requested a review from tompng May 25, 2024 15:14
@@ -173,7 +173,7 @@ def read_lines(lines, file = nil)

no += 1

line = line.chomp.lstrip
line = line.gsub(/#.*$/, '').chomp.strip
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for making confusion, I think we don't need to explicitly implement inline comment because readline does not have it.
But we need to retain set editing-mode vi # pseudo inline comment ignoring " # pseudo inline comment" part because readline ignores it and act like inline comment exist in some directives.
It is already implemented in L186

# value ignores " # pseudo comment" part. raw_value does not.
var, value, raw_value = $1.downcase, $2.partition(' ').first, $2

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

because readline does not have it.

Sorry for not getting the whole picture 💦 Removed this change!

Copy link
Member

@tompng tompng left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. Thank you 👍

@tompng tompng merged commit d60f1e1 into ruby:master May 26, 2024
40 checks passed
matzbot pushed a commit to ruby/ruby that referenced this pull request May 26, 2024
(ruby/reline#705)

* allow space in config value

fix ruby/reline#657

* remove inline comments

* Revert "remove inline comments"

This reverts commit ruby/reline@2438347c1a10.

* refactoring

* remove unnecessary comment handling

ruby/reline@d60f1e1e39
@ima1zumi ima1zumi added the bug Something isn't working label May 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Development

Successfully merging this pull request may close these issues.

Cursor offset with show-mode-in-prompt string
3 participants