use anyhow::anyhow; use buffer_diff::BufferDiff; use collections::{HashMap, HashSet}; use futures::{ channel::{mpsc, oneshot}, pin_mut, SinkExt, StreamExt, }; use gpui::{AppContext, AsyncApp, Context, Entity, Task, WeakEntity}; use language::Buffer; use mlua::{ExternalResult, Lua, MultiValue, ObjectLike, Table, UserData, UserDataMethods}; use parking_lot::Mutex; use project::{search::SearchQuery, Fs, Project, ProjectPath, WorktreeId}; use regex::Regex; use std::{ path::{Path, PathBuf}, sync::Arc, }; use util::{paths::PathMatcher, ResultExt}; struct ForegroundFn(Box, AsyncApp) + Send>); struct BufferChanges { diff: Entity, edit_ids: Vec, } pub struct ScriptingSession { project: Entity, scripts: Vec