Multicursor vim registers (#13025)
Release Notes: - vim: Added support for multicursor registers (#11687) - vim: Added support for the `"/` register
This commit is contained in:
parent
068b1c235c
commit
a5af5b2883
17 changed files with 333 additions and 250 deletions
|
@ -3,10 +3,11 @@ use std::{fmt::Display, ops::Range, sync::Arc};
|
|||
use crate::surrounds::SurroundsType;
|
||||
use crate::{motion::Motion, object::Object};
|
||||
use collections::HashMap;
|
||||
use editor::Anchor;
|
||||
use gpui::{Action, KeyContext};
|
||||
use editor::{Anchor, ClipboardSelection};
|
||||
use gpui::{Action, ClipboardItem, KeyContext};
|
||||
use language::{CursorShape, Selection, TransactionId};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use ui::SharedString;
|
||||
use workspace::searchable::Direction;
|
||||
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq, Deserialize, Serialize)]
|
||||
|
@ -113,6 +114,41 @@ pub enum RecordedSelection {
|
|||
},
|
||||
}
|
||||
|
||||
#[derive(Default, Clone, Debug)]
|
||||
pub struct Register {
|
||||
pub(crate) text: SharedString,
|
||||
pub(crate) clipboard_selections: Option<Vec<ClipboardSelection>>,
|
||||
}
|
||||
|
||||
impl From<Register> for ClipboardItem {
|
||||
fn from(register: Register) -> Self {
|
||||
let item = ClipboardItem::new(register.text.into());
|
||||
if let Some(clipboard_selections) = register.clipboard_selections {
|
||||
item.with_metadata(clipboard_selections)
|
||||
} else {
|
||||
item
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl From<ClipboardItem> for Register {
|
||||
fn from(value: ClipboardItem) -> Self {
|
||||
Register {
|
||||
text: value.text().to_owned().into(),
|
||||
clipboard_selections: value.metadata::<Vec<ClipboardSelection>>(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl From<String> for Register {
|
||||
fn from(text: String) -> Self {
|
||||
Register {
|
||||
text: text.into(),
|
||||
clipboard_selections: None,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Default, Clone)]
|
||||
pub struct WorkspaceState {
|
||||
pub search: SearchState,
|
||||
|
@ -125,7 +161,8 @@ pub struct WorkspaceState {
|
|||
pub recorded_actions: Vec<ReplayableAction>,
|
||||
pub recorded_selection: RecordedSelection,
|
||||
|
||||
pub registers: HashMap<char, String>,
|
||||
pub last_yank: Option<SharedString>,
|
||||
pub registers: HashMap<char, Register>,
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue