feat: Add --editor switch to specify editor for /editor command

This commit is contained in:
Paul Gauthier (aider) 2024-11-21 09:52:14 -08:00
parent b96b36d5ea
commit 2a387707ef
3 changed files with 22 additions and 3 deletions

View file

@ -738,6 +738,10 @@ def get_parser(default_config_files, git_root):
default=True,
help="Enable/disable fancy input with history and completion (default: True)",
)
group.add_argument(
"--editor",
help="Specify which editor to use for the /editor command",
)
##########
group = parser.add_argument_group("Voice Settings")

View file

@ -46,7 +46,15 @@ class Commands:
)
def __init__(
self, io, coder, voice_language=None, verify_ssl=True, args=None, parser=None, verbose=False
self,
io,
coder,
voice_language=None,
verify_ssl=True,
args=None,
parser=None,
verbose=False,
editor=None,
):
self.io = io
self.coder = coder
@ -61,6 +69,7 @@ class Commands:
self.voice_language = voice_language
self.help = None
self.editor = editor
def cmd_model(self, args):
"Switch to a new LLM"
@ -1355,7 +1364,7 @@ class Commands:
def cmd_editor(self, initial_content=""):
"Open an editor to write a prompt"
user_input = pipe_editor(initial_content, suffix="md")
user_input = pipe_editor(initial_content, suffix="md", editor=self.editor)
self.io.user_input(user_input, log_only=False)
self.io.add_to_input_history(user_input)
return user_input

View file

@ -689,7 +689,13 @@ def main(argv=None, input=None, output=None, force_git_root=None, return_coder=F
return 1
commands = Commands(
io, None, verify_ssl=args.verify_ssl, args=args, parser=parser, verbose=args.verbose
io,
None,
verify_ssl=args.verify_ssl,
args=args,
parser=parser,
verbose=args.verbose,
editor=args.editor,
)
summarizer = ChatSummary(