Configure Highlight settings on yank vim (#21479)
Release Notes: - Add settings / config variables to control `highlight_on_yank` or `highlight_on_copy` --------- Co-authored-by: Conrad Irwin <conrad.irwin@gmail.com>
This commit is contained in:
parent
207eb51df1
commit
5948ea217b
4 changed files with 10 additions and 3 deletions
|
@ -4,13 +4,14 @@ use crate::{
|
|||
motion::Motion,
|
||||
object::Object,
|
||||
state::{Mode, Register},
|
||||
Vim,
|
||||
Vim, VimSettings,
|
||||
};
|
||||
use collections::HashMap;
|
||||
use editor::{ClipboardSelection, Editor};
|
||||
use gpui::ViewContext;
|
||||
use language::Point;
|
||||
use multi_buffer::MultiBufferRow;
|
||||
use settings::Settings;
|
||||
|
||||
struct HighlightOnYank;
|
||||
|
||||
|
@ -195,7 +196,8 @@ impl Vim {
|
|||
)
|
||||
});
|
||||
|
||||
if !is_yank || self.mode == Mode::Visual {
|
||||
let highlight_duration = VimSettings::get_global(cx).highlight_on_yank_duration;
|
||||
if !is_yank || self.mode == Mode::Visual || highlight_duration == 0 {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -206,7 +208,7 @@ impl Vim {
|
|||
);
|
||||
cx.spawn(|this, mut cx| async move {
|
||||
cx.background_executor()
|
||||
.timer(Duration::from_millis(200))
|
||||
.timer(Duration::from_millis(highlight_duration))
|
||||
.await;
|
||||
this.update(&mut cx, |editor, cx| {
|
||||
editor.clear_background_highlights::<HighlightOnYank>(cx)
|
||||
|
|
|
@ -1199,6 +1199,7 @@ struct VimSettings {
|
|||
pub use_multiline_find: bool,
|
||||
pub use_smartcase_find: bool,
|
||||
pub custom_digraphs: HashMap<String, Arc<str>>,
|
||||
pub highlight_on_yank_duration: u64,
|
||||
}
|
||||
|
||||
#[derive(Clone, Default, Serialize, Deserialize, JsonSchema)]
|
||||
|
@ -1208,6 +1209,7 @@ struct VimSettingsContent {
|
|||
pub use_multiline_find: Option<bool>,
|
||||
pub use_smartcase_find: Option<bool>,
|
||||
pub custom_digraphs: Option<HashMap<String, Arc<str>>>,
|
||||
pub highlight_on_yank_duration: Option<u64>,
|
||||
}
|
||||
|
||||
impl Settings for VimSettings {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue