Prompts appear to need to be consistent for left arrow to calculate
...next location
Description
Per @fretb
It seems recent versions (has been going on for years afaik) chef-shell has a bug in its IRB prompts, when typing something and opening quotes, braces, ... the prompt changes (from chef (x.x.x)> to e.g. chef ">, this in turn changes the cursor location, but when using the arrow keys to go back, the cursor suddenly jumps to the end of the line as if the first prompt was still active. It's impossible to know where to start typing for instance to change chef "> tst " to chef "> test ", see where my cursor is when typing tst " and pushing arrow-left in a chef-shell prompt. I tested this on (an older) chef-shell prompt, it works fine there.
irb itself has this problem outside of Chef. Setting an .irbrc to the following breaks on [left arrow] if you are inside of an open quote for Ruby 3.1 and Ruby 3.2 versions that I have, but works as of Ruby 3.3.0. Ruby 3.0.6 also appears to have worked.
class Application
EXEC = "myapp"
VERSION = "2.0.1"
end
def leader
env_string = ENV["APP_ENV"] ? "(#{ENV["APP_ENV"]})" : ""
end
IRB.conf[:PROMPT][:CUSTOM] = {
PROMPT_C: "#{Application::EXEC}#{leader} > ",
RETURN_FORMAT: " => %s \n",
PROMPT_I: "#{Application::EXEC}#{leader} (#{Application::VERSION})> ",
PROMPT_N: "#{Application::EXEC}#{leader} ?> ",
PROMPT_S: "#{Application::EXEC}#{leader} %l> ",
}
IRB.conf[:PROMPT_MODE] = :CUSTOM
IRB.conf[:AUTO_INDENT] = true
Related Issue
Types of changes
- [ ] Bug fix (non-breaking change which fixes an issue)
- [ ] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing functionality to change)
- [ ] Chore (non-breaking change that does not add functionality or fix an issue)
Checklist:
- [ ] I have read the CONTRIBUTING document.
- [ ] I have run the pre-merge tests locally and they pass.
- [ ] I have updated the documentation accordingly.
- [ ] I have added tests to cover my changes.
- [ ] If
Gemfile.lockhas changed, I have used--conservativeto do it and included the full output in the Description above. - [ ] All new and existing tests passed.
- [ ] All commits have been signed-off for the Developer Certificate of Origin.
Quality Gate passed
Issues
0 New issues
0 Accepted issues
Measures
0 Security Hotspots
0.0% Coverage on New Code
62.9% Duplication on New Code