From b9daa09384a2d9018d25ee8ea20d6ed86cffd335 Mon Sep 17 00:00:00 2001 From: rapofran Date: Wed, 16 Jul 2025 11:09:10 -0300 Subject: [PATCH] Fixes within repl.rb --- lib/xi/repl.rb | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/lib/xi/repl.rb b/lib/xi/repl.rb index dc295a3..8c0a43d 100644 --- a/lib/xi/repl.rb +++ b/lib/xi/repl.rb @@ -25,15 +25,21 @@ def start(irb: false) def configure prepare_config_dir - if ENV["INSIDE_EMACS"] + prompts = if ENV["INSIDE_EMACS"] Pry.config.correct_indent = false Pry.config.pager = false - Pry.config.prompt = [ proc { "" }, proc { "" }] + [ proc { "" }, proc { "" }] else - Pry.config.prompt = [ proc { "xi> " }, proc { "..> " }] + [ proc { "xi> " }, proc { "..> " }] end + Pry::Prompt.new("Guard", "Guard Pry prompt", prompts) - Pry.config.history.file = history_path + # Pry >= 0.13 + if Pry.config.respond_to?(:history_file=) + Pry.config.history_file = history_path + else + Pry.config.history.file = history_path + end Pry.hooks.add_hook(:after_eval, "check_for_errors") do |result, pry| more_errors = ErrorLog.instance.more_errors? @@ -55,7 +61,7 @@ def load_init_script def prepare_config_dir FileUtils.mkdir_p(CONFIG_PATH) - unless File.exists?(init_script_path) + unless File.exist?(init_script_path) File.write(init_script_path, DEFAULT_INIT_SCRIPT) end end