use crate::folds::Fold;
pub struct Content {
pub(crate) text: ropey::Rope,
pub(crate) dirty_gen: u64,
pub(crate) folds: Vec<Fold>,
pub(crate) cached_joined: Option<(u64, std::sync::Arc<String>)>,
pub(crate) cached_byte_len: Option<(u64, usize)>,
pub(crate) undo_stack: Vec<crate::UndoEntry>,
pub(crate) redo_stack: Vec<crate::UndoEntry>,
pub(crate) content_dirty: bool,
pub(crate) cached_editor_content: Option<std::sync::Arc<String>>,
pub(crate) pending_fold_ops: Vec<crate::FoldOp>,
pub(crate) change_log: Vec<crate::EngineEdit>,
pub(crate) pending_content_edits: Vec<crate::ContentEdit>,
pub(crate) pending_content_reset: bool,
pub(crate) marks: std::collections::BTreeMap<char, (usize, usize)>,
pub(crate) syntax_fold_ranges: Vec<(usize, usize)>,
}
impl Default for Content {
fn default() -> Self {
Self::new()
}
}
impl Content {
pub fn new() -> Self {
Self {
text: ropey::Rope::new(),
dirty_gen: 0,
folds: Vec::new(),
cached_joined: None,
cached_byte_len: None,
undo_stack: Vec::new(),
redo_stack: Vec::new(),
content_dirty: false,
cached_editor_content: None,
pending_fold_ops: Vec::new(),
change_log: Vec::new(),
pending_content_edits: Vec::new(),
pending_content_reset: false,
marks: std::collections::BTreeMap::new(),
syntax_fold_ranges: Vec::new(),
}
}
#[allow(clippy::should_implement_trait)]
pub fn from_str(text: &str) -> Self {
Self {
text: ropey::Rope::from_str(text),
dirty_gen: 0,
folds: Vec::new(),
cached_joined: None,
cached_byte_len: None,
undo_stack: Vec::new(),
redo_stack: Vec::new(),
content_dirty: false,
cached_editor_content: None,
pending_fold_ops: Vec::new(),
change_log: Vec::new(),
pending_content_edits: Vec::new(),
pending_content_reset: false,
marks: std::collections::BTreeMap::new(),
syntax_fold_ranges: Vec::new(),
}
}
}