This commit is contained in:
Antonio Scandurra 2021-11-19 15:31:33 +01:00
parent 2664dad2bc
commit dfbfa86548
3 changed files with 84 additions and 11 deletions

View file

@ -10,7 +10,10 @@ use buffer::Rope;
use fold_map::{FoldMap, ToFoldPoint as _};
use gpui::{fonts::FontId, AppContext, Entity, ModelContext, ModelHandle};
use language::{Anchor, Buffer, Point, ToOffset, ToPoint};
use std::{collections::HashSet, ops::Range};
use std::{
collections::{HashMap, HashSet},
ops::Range,
};
use sum_tree::Bias;
use tab_map::TabMap;
use theme::{BlockStyle, SyntaxTheme};
@ -128,6 +131,13 @@ impl DisplayMap {
block_map.insert(blocks, cx)
}
pub fn restyle_blocks<F>(&mut self, styles: HashMap<BlockId, Option<F>>)
where
F: 'static + Fn(&AppContext) -> BlockStyle,
{
self.block_map.restyle(styles);
}
pub fn remove_blocks(&mut self, ids: HashSet<BlockId>, cx: &mut ModelContext<Self>) {
let (snapshot, edits) = self.fold_map.read(cx);
let (snapshot, edits) = self.tab_map.sync(snapshot, edits);