mirror of
https://github.com/Aider-AI/aider.git
synced 2025-05-30 17:24:59 +00:00
refactor: extract URL opening functionality into dedicated io.offer_url method
This commit is contained in:
parent
2cf93ccb54
commit
0368c3fae9
2 changed files with 10 additions and 3 deletions
|
@ -829,9 +829,7 @@ class Coder:
|
||||||
urls = list(set(url_pattern.findall(text))) # Use set to remove duplicates
|
urls = list(set(url_pattern.findall(text))) # Use set to remove duplicates
|
||||||
for url in urls:
|
for url in urls:
|
||||||
url = url.rstrip(".',\"")
|
url = url.rstrip(".',\"")
|
||||||
#ai refactor this into a io.offer_url() function!
|
self.io.offer_url(url)
|
||||||
if self.io.confirm_ask("Open URL for more info?", subject=url):
|
|
||||||
webbrowser.open(url)
|
|
||||||
return urls
|
return urls
|
||||||
|
|
||||||
def check_for_urls(self, inp: str) -> List[str]:
|
def check_for_urls(self, inp: str) -> List[str]:
|
||||||
|
|
|
@ -485,6 +485,15 @@ class InputOutput:
|
||||||
hist = "\n" + content.strip() + "\n\n"
|
hist = "\n" + content.strip() + "\n\n"
|
||||||
self.append_chat_history(hist)
|
self.append_chat_history(hist)
|
||||||
|
|
||||||
|
def offer_url(self, url, prompt="Open URL for more info?"):
|
||||||
|
"""Offer to open a URL in the browser, returns True if opened."""
|
||||||
|
if url.rstrip(".',\"") in self.never_prompts:
|
||||||
|
return False
|
||||||
|
if self.confirm_ask(prompt, subject=url, allow_never=True):
|
||||||
|
webbrowser.open(url)
|
||||||
|
return True
|
||||||
|
return False
|
||||||
|
|
||||||
def confirm_ask(
|
def confirm_ask(
|
||||||
self,
|
self,
|
||||||
question,
|
question,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue