Module: Irb::Autosuggestions::LineEditorPatch
- Defined in:
- lib/irb/autosuggestions/line_editor_patch.rb
Overview
Patches Reline::LineEditor to display fish-like autosuggestions from history. rubocop:disable Metrics/ModuleLength, SortedMethodsByCall/Waterfall
Constant Summary collapse
- GRAY =
"\e[90m"- DIM =
"\e[2m"- RESET_COLOR =
"\e[39;49m"- RESET =
"\e[0m"- FG_COLORS =
((30..37).to_a + (90..97).to_a + [38, 39]).freeze
- CONFIG_KEY =
:USE_AUTOSUGGESTIONS- ENV_KEY =
'IRB_AUTOSUGGESTIONS'- CONFIG_NAV_KEY =
:USE_PREFIX_HISTORY_NAVIGATION- ENV_NAV_KEY =
'IRB_PREFIX_HISTORY_NAVIGATION'
Instance Method Summary collapse
-
#input_key(key) ⇒ Object
Intercepts key input to accept autosuggestions on right arrow and clears the prefix navigation anchor on non-history keys.
Instance Method Details
#input_key(key) ⇒ Object
Intercepts key input to accept autosuggestions on right arrow and clears the prefix navigation anchor on non-history keys.
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/irb/autosuggestions/line_editor_patch.rb', line 23 def input_key(key) clear_prefix_anchor if && !(key) if enabled? && right_arrow?(key) buffer = whole_buffer suggestion = find_suggestion(buffer) if suggestion && suggestion != buffer accept_suggestion(suggestion) return end end super end |