From b2f86f2899b79b291eb56435f99402509105b7ec Mon Sep 17 00:00:00 2001 From: sigoden Date: Sat, 2 Mar 2024 22:02:29 +0800 Subject: refactor: auto_copy works when executing command (#328) --- src/config/mod.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'src/config/mod.rs') diff --git a/src/config/mod.rs b/src/config/mod.rs index 6b99483..cbf1020 100644 --- a/src/config/mod.rs +++ b/src/config/mod.rs @@ -11,7 +11,7 @@ use crate::client::{ Model, OpenAIClient, SendData, }; use crate::render::{MarkdownRender, RenderOptions}; -use crate::utils::{get_env_name, light_theme_from_colorfgbg, now, render_prompt}; +use crate::utils::{get_env_name, light_theme_from_colorfgbg, now, render_prompt, set_text}; use anyhow::{anyhow, bail, Context, Result}; use inquire::{Confirm, Select, Text}; @@ -247,6 +247,12 @@ impl Config { .with_context(|| "Failed to save message") } + pub fn maybe_copy(&self, text: &str) { + if self.auto_copy { + let _ = set_text(text); + } + } + pub fn config_file() -> Result { Self::local_path(CONFIG_FILE_NAME) } -- cgit v1.2.3