Skip to content

Stop cluttering the input history with Confirm/Ask responses: y/n/a/d #3958

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions aider/io.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,31 @@ def wrapper(self, *args, **kwargs):
return wrapper


def without_input_history(func):
"""Decorator to temporarily disable history saving for the prompt session buffer."""

@functools.wraps(func)
def wrapper(self, *args, **kwargs):
orig_buf_append = None
try:
orig_buf_append = self.prompt_session.default_buffer.append_to_history
self.prompt_session.default_buffer.append_to_history = (
lambda: None
) # Replace with no-op
except AttributeError:
pass

try:
return func(self, *args, **kwargs)
except Exception:
raise
finally:
if orig_buf_append:
self.prompt_session.default_buffer.append_to_history = orig_buf_append

return wrapper


class CommandCompletionException(Exception):
"""Raised when a command should use the normal autocompleter instead of
command-specific completion."""
Expand Down Expand Up @@ -793,6 +818,7 @@ def offer_url(self, url, prompt="Open URL for more info?", allow_never=True):
return False

@restore_multiline
@without_input_history
def confirm_ask(
self,
question,
Expand Down
Loading