Skip to content

Commit 9334687

Browse files
committed
drop bookkept blocks
1 parent 208d3d6 commit 9334687

File tree

1 file changed

+8
-13
lines changed

1 file changed

+8
-13
lines changed

crates/runtimes/src/runtimes.rs

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -304,16 +304,10 @@ pub fn run(workspace: &mut Workspace, _: &Run, cx: &mut ViewContext<Workspace>)
304304
let entity_id = editor.entity_id();
305305
let execution_id = ExecutionId::new();
306306

307-
// Since we don't know the height, in editor terms, we have to calculate it over time
308-
// and just create a new block, replacing the old. It would be better if we could
309-
// just rely on the view updating and for the height to be calculated automatically.
310-
//
311-
// We will just handle text for the moment to keep this accurate.
312-
// Plots and other images will have to wait.
313307
let execution_view = cx.new_view(|cx| ExecutionView::new(execution_id.clone(), cx));
314308

315309
// If any block overlaps with the new block, remove it
316-
// When inserting a new block, put it in order so that search is efficient
310+
// TODO: When inserting a new block, put it in order so that search is efficient
317311
let blocks_to_remove = runtime_manager.update(cx, |runtime_manager, _cx| {
318312
// Get the current `EditorRuntimeState` for this runtime_manager, inserting it if it doesn't exist
319313
let editor_runtime_state = runtime_manager
@@ -322,13 +316,16 @@ pub fn run(workspace: &mut Workspace, _: &Run, cx: &mut ViewContext<Workspace>)
322316
.or_insert_with(|| EditorRuntimeState { blocks: Vec::new() });
323317

324318
let mut blocks_to_remove: HashSet<BlockId> = HashSet::default();
325-
for (_i, block) in editor_runtime_state.blocks.iter().enumerate() {
326-
let other_range: Range<Anchor> = block.code_range.clone();
327319

328-
if anchor_range.overlaps(&other_range, &buffer) {
320+
editor_runtime_state.blocks.retain(|block| {
321+
if anchor_range.overlaps(&block.code_range, &buffer) {
329322
blocks_to_remove.insert(block.block_id);
323+
// Drop this block
324+
false
325+
} else {
326+
true
330327
}
331-
}
328+
});
332329

333330
blocks_to_remove
334331
});
@@ -348,8 +345,6 @@ pub fn run(workspace: &mut Workspace, _: &Run, cx: &mut ViewContext<Workspace>)
348345
editor.insert_blocks([block], None, cx)[0]
349346
});
350347

351-
println!("Created block {block_id:?}");
352-
353348
let receiver = runtime_manager.update(cx, |runtime_manager, cx| {
354349
let editor_runtime_state = runtime_manager
355350
.editors

0 commit comments

Comments
 (0)