mirror of
https://github.com/zed-industries/zed.git
synced 2024-12-26 09:22:42 +03:00
Finished refactoring out fs and rope
This commit is contained in:
parent
0a8e2f6bb0
commit
0beb97547e
44
Cargo.lock
generated
44
Cargo.lock
generated
@ -1045,6 +1045,7 @@ dependencies = [
|
|||||||
"editor",
|
"editor",
|
||||||
"env_logger",
|
"env_logger",
|
||||||
"envy",
|
"envy",
|
||||||
|
"fs",
|
||||||
"futures",
|
"futures",
|
||||||
"git",
|
"git",
|
||||||
"gpui",
|
"gpui",
|
||||||
@ -1060,6 +1061,7 @@ dependencies = [
|
|||||||
"prometheus",
|
"prometheus",
|
||||||
"rand 0.8.5",
|
"rand 0.8.5",
|
||||||
"reqwest",
|
"reqwest",
|
||||||
|
"rope",
|
||||||
"rpc",
|
"rpc",
|
||||||
"scrypt",
|
"scrypt",
|
||||||
"serde",
|
"serde",
|
||||||
@ -1551,6 +1553,7 @@ dependencies = [
|
|||||||
"language",
|
"language",
|
||||||
"postage",
|
"postage",
|
||||||
"project",
|
"project",
|
||||||
|
"rope",
|
||||||
"serde_json",
|
"serde_json",
|
||||||
"settings",
|
"settings",
|
||||||
"smallvec",
|
"smallvec",
|
||||||
@ -1704,6 +1707,7 @@ dependencies = [
|
|||||||
"postage",
|
"postage",
|
||||||
"project",
|
"project",
|
||||||
"rand 0.8.5",
|
"rand 0.8.5",
|
||||||
|
"rope",
|
||||||
"rpc",
|
"rpc",
|
||||||
"serde",
|
"serde",
|
||||||
"settings",
|
"settings",
|
||||||
@ -1993,10 +1997,18 @@ dependencies = [
|
|||||||
"collections",
|
"collections",
|
||||||
"fsevent",
|
"fsevent",
|
||||||
"futures",
|
"futures",
|
||||||
"git",
|
"git2",
|
||||||
|
"gpui",
|
||||||
|
"lazy_static",
|
||||||
|
"libc",
|
||||||
|
"log",
|
||||||
|
"lsp",
|
||||||
"parking_lot 0.11.2",
|
"parking_lot 0.11.2",
|
||||||
|
"regex",
|
||||||
|
"rope",
|
||||||
|
"serde",
|
||||||
|
"serde_json",
|
||||||
"smol",
|
"smol",
|
||||||
"text",
|
|
||||||
"util",
|
"util",
|
||||||
]
|
]
|
||||||
|
|
||||||
@ -2250,6 +2262,7 @@ dependencies = [
|
|||||||
"lazy_static",
|
"lazy_static",
|
||||||
"log",
|
"log",
|
||||||
"parking_lot 0.11.2",
|
"parking_lot 0.11.2",
|
||||||
|
"rope",
|
||||||
"smol",
|
"smol",
|
||||||
"sum_tree",
|
"sum_tree",
|
||||||
"text",
|
"text",
|
||||||
@ -2297,6 +2310,7 @@ dependencies = [
|
|||||||
"gpui",
|
"gpui",
|
||||||
"menu",
|
"menu",
|
||||||
"postage",
|
"postage",
|
||||||
|
"rope",
|
||||||
"settings",
|
"settings",
|
||||||
"text",
|
"text",
|
||||||
"workspace",
|
"workspace",
|
||||||
@ -2884,6 +2898,7 @@ dependencies = [
|
|||||||
"collections",
|
"collections",
|
||||||
"ctor",
|
"ctor",
|
||||||
"env_logger",
|
"env_logger",
|
||||||
|
"fs",
|
||||||
"futures",
|
"futures",
|
||||||
"fuzzy",
|
"fuzzy",
|
||||||
"git",
|
"git",
|
||||||
@ -2895,6 +2910,7 @@ dependencies = [
|
|||||||
"postage",
|
"postage",
|
||||||
"rand 0.8.5",
|
"rand 0.8.5",
|
||||||
"regex",
|
"regex",
|
||||||
|
"rope",
|
||||||
"rpc",
|
"rpc",
|
||||||
"serde",
|
"serde",
|
||||||
"serde_json",
|
"serde_json",
|
||||||
@ -4028,6 +4044,7 @@ dependencies = [
|
|||||||
"clock",
|
"clock",
|
||||||
"collections",
|
"collections",
|
||||||
"db",
|
"db",
|
||||||
|
"fs",
|
||||||
"fsevent",
|
"fsevent",
|
||||||
"futures",
|
"futures",
|
||||||
"fuzzy",
|
"fuzzy",
|
||||||
@ -4036,7 +4053,6 @@ dependencies = [
|
|||||||
"ignore",
|
"ignore",
|
||||||
"language",
|
"language",
|
||||||
"lazy_static",
|
"lazy_static",
|
||||||
"libc",
|
|
||||||
"log",
|
"log",
|
||||||
"lsp",
|
"lsp",
|
||||||
"parking_lot 0.11.2",
|
"parking_lot 0.11.2",
|
||||||
@ -4045,6 +4061,7 @@ dependencies = [
|
|||||||
"rand 0.8.5",
|
"rand 0.8.5",
|
||||||
"regex",
|
"regex",
|
||||||
"rocksdb",
|
"rocksdb",
|
||||||
|
"rope",
|
||||||
"rpc",
|
"rpc",
|
||||||
"serde",
|
"serde",
|
||||||
"serde_json",
|
"serde_json",
|
||||||
@ -4531,6 +4548,20 @@ dependencies = [
|
|||||||
"librocksdb-sys",
|
"librocksdb-sys",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "rope"
|
||||||
|
version = "0.1.0"
|
||||||
|
dependencies = [
|
||||||
|
"arrayvec 0.7.2",
|
||||||
|
"bromberg_sl2",
|
||||||
|
"gpui",
|
||||||
|
"log",
|
||||||
|
"rand 0.8.5",
|
||||||
|
"smallvec",
|
||||||
|
"sum_tree",
|
||||||
|
"util",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "roxmltree"
|
name = "roxmltree"
|
||||||
version = "0.14.1"
|
version = "0.14.1"
|
||||||
@ -5588,13 +5619,12 @@ name = "text"
|
|||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"arrayvec 0.7.2",
|
|
||||||
"bromberg_sl2",
|
|
||||||
"clock",
|
"clock",
|
||||||
"collections",
|
"collections",
|
||||||
"ctor",
|
"ctor",
|
||||||
"digest 0.9.0",
|
"digest 0.9.0",
|
||||||
"env_logger",
|
"env_logger",
|
||||||
|
"fs",
|
||||||
"gpui",
|
"gpui",
|
||||||
"lazy_static",
|
"lazy_static",
|
||||||
"log",
|
"log",
|
||||||
@ -5602,6 +5632,7 @@ dependencies = [
|
|||||||
"postage",
|
"postage",
|
||||||
"rand 0.8.5",
|
"rand 0.8.5",
|
||||||
"regex",
|
"regex",
|
||||||
|
"rope",
|
||||||
"smallvec",
|
"smallvec",
|
||||||
"sum_tree",
|
"sum_tree",
|
||||||
"util",
|
"util",
|
||||||
@ -6504,6 +6535,7 @@ dependencies = [
|
|||||||
"language",
|
"language",
|
||||||
"log",
|
"log",
|
||||||
"project",
|
"project",
|
||||||
|
"rope",
|
||||||
"search",
|
"search",
|
||||||
"serde",
|
"serde",
|
||||||
"settings",
|
"settings",
|
||||||
@ -7192,6 +7224,7 @@ dependencies = [
|
|||||||
"collections",
|
"collections",
|
||||||
"context_menu",
|
"context_menu",
|
||||||
"drag_and_drop",
|
"drag_and_drop",
|
||||||
|
"fs",
|
||||||
"futures",
|
"futures",
|
||||||
"gpui",
|
"gpui",
|
||||||
"language",
|
"language",
|
||||||
@ -7275,6 +7308,7 @@ dependencies = [
|
|||||||
"editor",
|
"editor",
|
||||||
"env_logger",
|
"env_logger",
|
||||||
"file_finder",
|
"file_finder",
|
||||||
|
"fs",
|
||||||
"fsevent",
|
"fsevent",
|
||||||
"futures",
|
"futures",
|
||||||
"fuzzy",
|
"fuzzy",
|
||||||
|
@ -6,6 +6,7 @@ resolver = "2"
|
|||||||
[workspace.dependencies]
|
[workspace.dependencies]
|
||||||
serde = { version = "1.0", features = ["derive", "rc"] }
|
serde = { version = "1.0", features = ["derive", "rc"] }
|
||||||
serde_json = { version = "1.0", features = ["preserve_order", "raw_value"] }
|
serde_json = { version = "1.0", features = ["preserve_order", "raw_value"] }
|
||||||
|
rand = { version = "0.8" }
|
||||||
|
|
||||||
[patch.crates-io]
|
[patch.crates-io]
|
||||||
tree-sitter = { git = "https://github.com/tree-sitter/tree-sitter", rev = "366210ae925d7ea0891bc7a0c738f60c77c04d7b" }
|
tree-sitter = { git = "https://github.com/tree-sitter/tree-sitter", rev = "366210ae925d7ea0891bc7a0c738f60c77c04d7b" }
|
||||||
|
@ -16,7 +16,8 @@ required-features = ["seed-support"]
|
|||||||
collections = { path = "../collections" }
|
collections = { path = "../collections" }
|
||||||
rpc = { path = "../rpc" }
|
rpc = { path = "../rpc" }
|
||||||
util = { path = "../util" }
|
util = { path = "../util" }
|
||||||
|
fs = { path = "../fs" }
|
||||||
|
rope = { path = "../rope" }
|
||||||
anyhow = "1.0.40"
|
anyhow = "1.0.40"
|
||||||
async-trait = "0.1.50"
|
async-trait = "0.1.50"
|
||||||
async-tungstenite = "0.16"
|
async-tungstenite = "0.16"
|
||||||
|
@ -15,6 +15,7 @@ use editor::{
|
|||||||
self, ConfirmCodeAction, ConfirmCompletion, ConfirmRename, Editor, Redo, Rename, ToOffset,
|
self, ConfirmCodeAction, ConfirmCompletion, ConfirmRename, Editor, Redo, Rename, ToOffset,
|
||||||
ToggleCodeActions, Undo,
|
ToggleCodeActions, Undo,
|
||||||
};
|
};
|
||||||
|
use fs::{FakeFs, Fs as _, LineEnding};
|
||||||
use futures::{channel::mpsc, Future, StreamExt as _};
|
use futures::{channel::mpsc, Future, StreamExt as _};
|
||||||
use gpui::{
|
use gpui::{
|
||||||
executor::{self, Deterministic},
|
executor::{self, Deterministic},
|
||||||
@ -24,17 +25,16 @@ use gpui::{
|
|||||||
};
|
};
|
||||||
use language::{
|
use language::{
|
||||||
range_to_lsp, tree_sitter_rust, Diagnostic, DiagnosticEntry, FakeLspAdapter, Language,
|
range_to_lsp, tree_sitter_rust, Diagnostic, DiagnosticEntry, FakeLspAdapter, Language,
|
||||||
LanguageConfig, LanguageRegistry, LineEnding, OffsetRangeExt, Point, Rope,
|
LanguageConfig, LanguageRegistry, OffsetRangeExt, Rope,
|
||||||
};
|
};
|
||||||
use lsp::{self, FakeLanguageServer};
|
use lsp::{self, FakeLanguageServer};
|
||||||
use parking_lot::Mutex;
|
use parking_lot::Mutex;
|
||||||
use project::{
|
use project::{
|
||||||
fs::{FakeFs, Fs as _},
|
search::SearchQuery, worktree::WorktreeHandle, DiagnosticSummary, Project, ProjectPath,
|
||||||
search::SearchQuery,
|
ProjectStore, WorktreeId,
|
||||||
worktree::WorktreeHandle,
|
|
||||||
DiagnosticSummary, Project, ProjectPath, ProjectStore, WorktreeId,
|
|
||||||
};
|
};
|
||||||
use rand::prelude::*;
|
use rand::prelude::*;
|
||||||
|
use rope::point::Point;
|
||||||
use rpc::PeerId;
|
use rpc::PeerId;
|
||||||
use serde_json::json;
|
use serde_json::json;
|
||||||
use settings::{Formatter, Settings};
|
use settings::{Formatter, Settings};
|
||||||
|
@ -15,6 +15,7 @@ editor = { path = "../editor" }
|
|||||||
language = { path = "../language" }
|
language = { path = "../language" }
|
||||||
gpui = { path = "../gpui" }
|
gpui = { path = "../gpui" }
|
||||||
project = { path = "../project" }
|
project = { path = "../project" }
|
||||||
|
rope = { path = "../rope" }
|
||||||
settings = { path = "../settings" }
|
settings = { path = "../settings" }
|
||||||
theme = { path = "../theme" }
|
theme = { path = "../theme" }
|
||||||
util = { path = "../util" }
|
util = { path = "../util" }
|
||||||
|
@ -14,10 +14,10 @@ use gpui::{
|
|||||||
ViewHandle, WeakViewHandle,
|
ViewHandle, WeakViewHandle,
|
||||||
};
|
};
|
||||||
use language::{
|
use language::{
|
||||||
Anchor, Bias, Buffer, Diagnostic, DiagnosticEntry, DiagnosticSeverity, Point, Selection,
|
Anchor, Bias, Buffer, Diagnostic, DiagnosticEntry, DiagnosticSeverity, Selection, SelectionGoal,
|
||||||
SelectionGoal,
|
|
||||||
};
|
};
|
||||||
use project::{DiagnosticSummary, Project, ProjectPath};
|
use project::{DiagnosticSummary, Project, ProjectPath};
|
||||||
|
use rope::point::Point;
|
||||||
use serde_json::json;
|
use serde_json::json;
|
||||||
use settings::Settings;
|
use settings::Settings;
|
||||||
use smallvec::SmallVec;
|
use smallvec::SmallVec;
|
||||||
@ -738,7 +738,8 @@ mod tests {
|
|||||||
DisplayPoint,
|
DisplayPoint,
|
||||||
};
|
};
|
||||||
use gpui::TestAppContext;
|
use gpui::TestAppContext;
|
||||||
use language::{Diagnostic, DiagnosticEntry, DiagnosticSeverity, PointUtf16};
|
use language::{Diagnostic, DiagnosticEntry, DiagnosticSeverity};
|
||||||
|
use rope::point_utf16::PointUtf16;
|
||||||
use serde_json::json;
|
use serde_json::json;
|
||||||
use unindent::Unindent as _;
|
use unindent::Unindent as _;
|
||||||
use workspace::AppState;
|
use workspace::AppState;
|
||||||
|
@ -30,6 +30,7 @@ gpui = { path = "../gpui" }
|
|||||||
language = { path = "../language" }
|
language = { path = "../language" }
|
||||||
lsp = { path = "../lsp" }
|
lsp = { path = "../lsp" }
|
||||||
project = { path = "../project" }
|
project = { path = "../project" }
|
||||||
|
rope = { path = "../rope" }
|
||||||
rpc = { path = "../rpc" }
|
rpc = { path = "../rpc" }
|
||||||
settings = { path = "../settings" }
|
settings = { path = "../settings" }
|
||||||
snippet = { path = "../snippet" }
|
snippet = { path = "../snippet" }
|
||||||
|
@ -11,7 +11,8 @@ use gpui::{
|
|||||||
fonts::{FontId, HighlightStyle},
|
fonts::{FontId, HighlightStyle},
|
||||||
Entity, ModelContext, ModelHandle,
|
Entity, ModelContext, ModelHandle,
|
||||||
};
|
};
|
||||||
use language::{OffsetUtf16, Point, Subscription as BufferSubscription};
|
use language::Subscription as BufferSubscription;
|
||||||
|
use rope::{offset_utf16::OffsetUtf16, point::Point};
|
||||||
use settings::Settings;
|
use settings::Settings;
|
||||||
use std::{any::TypeId, fmt::Debug, num::NonZeroU32, ops::Range, sync::Arc};
|
use std::{any::TypeId, fmt::Debug, num::NonZeroU32, ops::Range, sync::Arc};
|
||||||
use sum_tree::{Bias, TreeMap};
|
use sum_tree::{Bias, TreeMap};
|
||||||
@ -565,7 +566,7 @@ pub mod tests {
|
|||||||
use super::*;
|
use super::*;
|
||||||
use crate::{movement, test::marked_display_snapshot};
|
use crate::{movement, test::marked_display_snapshot};
|
||||||
use gpui::{color::Color, elements::*, test::observe, MutableAppContext};
|
use gpui::{color::Color, elements::*, test::observe, MutableAppContext};
|
||||||
use language::{Buffer, Language, LanguageConfig, RandomCharIter, SelectionGoal};
|
use language::{Buffer, Language, LanguageConfig, SelectionGoal};
|
||||||
use rand::{prelude::*, Rng};
|
use rand::{prelude::*, Rng};
|
||||||
use smol::stream::StreamExt;
|
use smol::stream::StreamExt;
|
||||||
use std::{env, sync::Arc};
|
use std::{env, sync::Arc};
|
||||||
@ -609,7 +610,9 @@ pub mod tests {
|
|||||||
let buffer = cx.update(|cx| {
|
let buffer = cx.update(|cx| {
|
||||||
if rng.gen() {
|
if rng.gen() {
|
||||||
let len = rng.gen_range(0..10);
|
let len = rng.gen_range(0..10);
|
||||||
let text = RandomCharIter::new(&mut rng).take(len).collect::<String>();
|
let text = util::RandomCharIter::new(&mut rng)
|
||||||
|
.take(len)
|
||||||
|
.collect::<String>();
|
||||||
MultiBuffer::build_simple(&text, cx)
|
MultiBuffer::build_simple(&text, cx)
|
||||||
} else {
|
} else {
|
||||||
MultiBuffer::build_random(&mut rng, cx)
|
MultiBuffer::build_random(&mut rng, cx)
|
||||||
|
@ -7,6 +7,7 @@ use collections::{Bound, HashMap, HashSet};
|
|||||||
use gpui::{ElementBox, RenderContext};
|
use gpui::{ElementBox, RenderContext};
|
||||||
use language::{BufferSnapshot, Chunk, Patch};
|
use language::{BufferSnapshot, Chunk, Patch};
|
||||||
use parking_lot::Mutex;
|
use parking_lot::Mutex;
|
||||||
|
use rope::point::Point;
|
||||||
use std::{
|
use std::{
|
||||||
cell::RefCell,
|
cell::RefCell,
|
||||||
cmp::{self, Ordering},
|
cmp::{self, Ordering},
|
||||||
@ -18,7 +19,7 @@ use std::{
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
use sum_tree::{Bias, SumTree};
|
use sum_tree::{Bias, SumTree};
|
||||||
use text::{Edit, Point};
|
use text::Edit;
|
||||||
|
|
||||||
const NEWLINES: &[u8] = &[b'\n'; u8::MAX as usize];
|
const NEWLINES: &[u8] = &[b'\n'; u8::MAX as usize];
|
||||||
|
|
||||||
@ -42,7 +43,7 @@ pub struct BlockSnapshot {
|
|||||||
pub struct BlockId(usize);
|
pub struct BlockId(usize);
|
||||||
|
|
||||||
#[derive(Copy, Clone, Debug, Default, Eq, Ord, PartialOrd, PartialEq)]
|
#[derive(Copy, Clone, Debug, Default, Eq, Ord, PartialOrd, PartialEq)]
|
||||||
pub struct BlockPoint(pub super::Point);
|
pub struct BlockPoint(pub Point);
|
||||||
|
|
||||||
#[derive(Copy, Clone, Debug, Default, Eq, Ord, PartialOrd, PartialEq)]
|
#[derive(Copy, Clone, Debug, Default, Eq, Ord, PartialOrd, PartialEq)]
|
||||||
struct BlockRow(u32);
|
struct BlockRow(u32);
|
||||||
@ -994,7 +995,7 @@ mod tests {
|
|||||||
use rand::prelude::*;
|
use rand::prelude::*;
|
||||||
use settings::Settings;
|
use settings::Settings;
|
||||||
use std::env;
|
use std::env;
|
||||||
use text::RandomCharIter;
|
use util::RandomCharIter;
|
||||||
|
|
||||||
#[gpui::test]
|
#[gpui::test]
|
||||||
fn test_offset_for_row() {
|
fn test_offset_for_row() {
|
||||||
|
@ -5,8 +5,9 @@ use crate::{
|
|||||||
};
|
};
|
||||||
use collections::BTreeMap;
|
use collections::BTreeMap;
|
||||||
use gpui::fonts::HighlightStyle;
|
use gpui::fonts::HighlightStyle;
|
||||||
use language::{Chunk, Edit, Point, TextSummary};
|
use language::{Chunk, Edit, TextSummary};
|
||||||
use parking_lot::Mutex;
|
use parking_lot::Mutex;
|
||||||
|
use rope::point::Point;
|
||||||
use std::{
|
use std::{
|
||||||
any::TypeId,
|
any::TypeId,
|
||||||
cmp::{self, Ordering},
|
cmp::{self, Ordering},
|
||||||
@ -18,11 +19,11 @@ use std::{
|
|||||||
use sum_tree::{Bias, Cursor, FilterCursor, SumTree};
|
use sum_tree::{Bias, Cursor, FilterCursor, SumTree};
|
||||||
|
|
||||||
#[derive(Copy, Clone, Debug, Default, Eq, Ord, PartialOrd, PartialEq)]
|
#[derive(Copy, Clone, Debug, Default, Eq, Ord, PartialOrd, PartialEq)]
|
||||||
pub struct FoldPoint(pub super::Point);
|
pub struct FoldPoint(pub Point);
|
||||||
|
|
||||||
impl FoldPoint {
|
impl FoldPoint {
|
||||||
pub fn new(row: u32, column: u32) -> Self {
|
pub fn new(row: u32, column: u32) -> Self {
|
||||||
Self(super::Point::new(row, column))
|
Self(Point::new(row, column))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn row(self) -> u32 {
|
pub fn row(self) -> u32 {
|
||||||
@ -1196,8 +1197,8 @@ mod tests {
|
|||||||
use settings::Settings;
|
use settings::Settings;
|
||||||
use std::{cmp::Reverse, env, mem, sync::Arc};
|
use std::{cmp::Reverse, env, mem, sync::Arc};
|
||||||
use sum_tree::TreeMap;
|
use sum_tree::TreeMap;
|
||||||
use text::RandomCharIter;
|
|
||||||
use util::test::sample_text;
|
use util::test::sample_text;
|
||||||
|
use util::RandomCharIter;
|
||||||
use Bias::{Left, Right};
|
use Bias::{Left, Right};
|
||||||
|
|
||||||
#[gpui::test]
|
#[gpui::test]
|
||||||
|
@ -3,11 +3,12 @@ use super::{
|
|||||||
TextHighlights,
|
TextHighlights,
|
||||||
};
|
};
|
||||||
use crate::MultiBufferSnapshot;
|
use crate::MultiBufferSnapshot;
|
||||||
use language::{rope, Chunk};
|
use language::Chunk;
|
||||||
use parking_lot::Mutex;
|
use parking_lot::Mutex;
|
||||||
|
use rope;
|
||||||
|
use rope::point::Point;
|
||||||
use std::{cmp, mem, num::NonZeroU32, ops::Range};
|
use std::{cmp, mem, num::NonZeroU32, ops::Range};
|
||||||
use sum_tree::Bias;
|
use sum_tree::Bias;
|
||||||
use text::Point;
|
|
||||||
|
|
||||||
pub struct TabMap(Mutex<TabSnapshot>);
|
pub struct TabMap(Mutex<TabSnapshot>);
|
||||||
|
|
||||||
@ -332,11 +333,11 @@ impl TabSnapshot {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Copy, Clone, Debug, Default, Eq, Ord, PartialOrd, PartialEq)]
|
#[derive(Copy, Clone, Debug, Default, Eq, Ord, PartialOrd, PartialEq)]
|
||||||
pub struct TabPoint(pub super::Point);
|
pub struct TabPoint(pub Point);
|
||||||
|
|
||||||
impl TabPoint {
|
impl TabPoint {
|
||||||
pub fn new(row: u32, column: u32) -> Self {
|
pub fn new(row: u32, column: u32) -> Self {
|
||||||
Self(super::Point::new(row, column))
|
Self(Point::new(row, column))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn zero() -> Self {
|
pub fn zero() -> Self {
|
||||||
@ -352,8 +353,8 @@ impl TabPoint {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<super::Point> for TabPoint {
|
impl From<Point> for TabPoint {
|
||||||
fn from(point: super::Point) -> Self {
|
fn from(point: Point) -> Self {
|
||||||
Self(point)
|
Self(point)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -362,7 +363,7 @@ pub type TabEdit = text::Edit<TabPoint>;
|
|||||||
|
|
||||||
#[derive(Clone, Debug, Default, Eq, PartialEq)]
|
#[derive(Clone, Debug, Default, Eq, PartialEq)]
|
||||||
pub struct TextSummary {
|
pub struct TextSummary {
|
||||||
pub lines: super::Point,
|
pub lines: Point,
|
||||||
pub first_line_chars: u32,
|
pub first_line_chars: u32,
|
||||||
pub last_line_chars: u32,
|
pub last_line_chars: u32,
|
||||||
pub longest_row: u32,
|
pub longest_row: u32,
|
||||||
@ -485,7 +486,6 @@ mod tests {
|
|||||||
use super::*;
|
use super::*;
|
||||||
use crate::{display_map::fold_map::FoldMap, MultiBuffer};
|
use crate::{display_map::fold_map::FoldMap, MultiBuffer};
|
||||||
use rand::{prelude::StdRng, Rng};
|
use rand::{prelude::StdRng, Rng};
|
||||||
use text::{RandomCharIter, Rope};
|
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_expand_tabs() {
|
fn test_expand_tabs() {
|
||||||
@ -508,7 +508,9 @@ mod tests {
|
|||||||
let tab_size = NonZeroU32::new(rng.gen_range(1..=4)).unwrap();
|
let tab_size = NonZeroU32::new(rng.gen_range(1..=4)).unwrap();
|
||||||
let len = rng.gen_range(0..30);
|
let len = rng.gen_range(0..30);
|
||||||
let buffer = if rng.gen() {
|
let buffer = if rng.gen() {
|
||||||
let text = RandomCharIter::new(&mut rng).take(len).collect::<String>();
|
let text = util::RandomCharIter::new(&mut rng)
|
||||||
|
.take(len)
|
||||||
|
.collect::<String>();
|
||||||
MultiBuffer::build_simple(&text, cx)
|
MultiBuffer::build_simple(&text, cx)
|
||||||
} else {
|
} else {
|
||||||
MultiBuffer::build_random(&mut rng, cx)
|
MultiBuffer::build_random(&mut rng, cx)
|
||||||
@ -522,7 +524,7 @@ mod tests {
|
|||||||
log::info!("FoldMap text: {:?}", folds_snapshot.text());
|
log::info!("FoldMap text: {:?}", folds_snapshot.text());
|
||||||
|
|
||||||
let (_, tabs_snapshot) = TabMap::new(folds_snapshot.clone(), tab_size);
|
let (_, tabs_snapshot) = TabMap::new(folds_snapshot.clone(), tab_size);
|
||||||
let text = Rope::from(tabs_snapshot.text().as_str());
|
let text = rope::Rope::from(tabs_snapshot.text().as_str());
|
||||||
log::info!(
|
log::info!(
|
||||||
"TabMap text (tab size: {}): {:?}",
|
"TabMap text (tab size: {}): {:?}",
|
||||||
tab_size,
|
tab_size,
|
||||||
|
@ -3,13 +3,14 @@ use super::{
|
|||||||
tab_map::{self, TabEdit, TabPoint, TabSnapshot},
|
tab_map::{self, TabEdit, TabPoint, TabSnapshot},
|
||||||
TextHighlights,
|
TextHighlights,
|
||||||
};
|
};
|
||||||
use crate::{MultiBufferSnapshot, Point};
|
use crate::MultiBufferSnapshot;
|
||||||
use gpui::{
|
use gpui::{
|
||||||
fonts::FontId, text_layout::LineWrapper, Entity, ModelContext, ModelHandle, MutableAppContext,
|
fonts::FontId, text_layout::LineWrapper, Entity, ModelContext, ModelHandle, MutableAppContext,
|
||||||
Task,
|
Task,
|
||||||
};
|
};
|
||||||
use language::Chunk;
|
use language::Chunk;
|
||||||
use lazy_static::lazy_static;
|
use lazy_static::lazy_static;
|
||||||
|
use rope::point::Point;
|
||||||
use smol::future::yield_now;
|
use smol::future::yield_now;
|
||||||
use std::{cmp, collections::VecDeque, mem, ops::Range, time::Duration};
|
use std::{cmp, collections::VecDeque, mem, ops::Range, time::Duration};
|
||||||
use sum_tree::{Bias, Cursor, SumTree};
|
use sum_tree::{Bias, Cursor, SumTree};
|
||||||
@ -52,7 +53,7 @@ struct TransformSummary {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Copy, Clone, Debug, Default, Eq, Ord, PartialOrd, PartialEq)]
|
#[derive(Copy, Clone, Debug, Default, Eq, Ord, PartialOrd, PartialEq)]
|
||||||
pub struct WrapPoint(pub super::Point);
|
pub struct WrapPoint(pub Point);
|
||||||
|
|
||||||
pub struct WrapChunks<'a> {
|
pub struct WrapChunks<'a> {
|
||||||
input_chunks: tab_map::TabChunks<'a>,
|
input_chunks: tab_map::TabChunks<'a>,
|
||||||
@ -959,7 +960,7 @@ impl SumTreeExt for SumTree<Transform> {
|
|||||||
|
|
||||||
impl WrapPoint {
|
impl WrapPoint {
|
||||||
pub fn new(row: u32, column: u32) -> Self {
|
pub fn new(row: u32, column: u32) -> Self {
|
||||||
Self(super::Point::new(row, column))
|
Self(Point::new(row, column))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn row(self) -> u32 {
|
pub fn row(self) -> u32 {
|
||||||
@ -1029,7 +1030,6 @@ mod tests {
|
|||||||
MultiBuffer,
|
MultiBuffer,
|
||||||
};
|
};
|
||||||
use gpui::test::observe;
|
use gpui::test::observe;
|
||||||
use language::RandomCharIter;
|
|
||||||
use rand::prelude::*;
|
use rand::prelude::*;
|
||||||
use settings::Settings;
|
use settings::Settings;
|
||||||
use smol::stream::StreamExt;
|
use smol::stream::StreamExt;
|
||||||
@ -1067,7 +1067,9 @@ mod tests {
|
|||||||
MultiBuffer::build_random(&mut rng, cx)
|
MultiBuffer::build_random(&mut rng, cx)
|
||||||
} else {
|
} else {
|
||||||
let len = rng.gen_range(0..10);
|
let len = rng.gen_range(0..10);
|
||||||
let text = RandomCharIter::new(&mut rng).take(len).collect::<String>();
|
let text = util::RandomCharIter::new(&mut rng)
|
||||||
|
.take(len)
|
||||||
|
.collect::<String>();
|
||||||
MultiBuffer::build_simple(&text, cx)
|
MultiBuffer::build_simple(&text, cx)
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -43,8 +43,8 @@ pub use items::MAX_TAB_TITLE_LEN;
|
|||||||
pub use language::{char_kind, CharKind};
|
pub use language::{char_kind, CharKind};
|
||||||
use language::{
|
use language::{
|
||||||
AutoindentMode, BracketPair, Buffer, CodeAction, CodeLabel, Completion, Diagnostic,
|
AutoindentMode, BracketPair, Buffer, CodeAction, CodeLabel, Completion, Diagnostic,
|
||||||
DiagnosticSeverity, IndentKind, IndentSize, Language, OffsetRangeExt, OffsetUtf16, Point,
|
DiagnosticSeverity, IndentKind, IndentSize, Language, OffsetRangeExt, Selection, SelectionGoal,
|
||||||
Selection, SelectionGoal, TransactionId,
|
TransactionId,
|
||||||
};
|
};
|
||||||
use link_go_to_definition::{hide_link_definition, LinkGoToDefinitionState};
|
use link_go_to_definition::{hide_link_definition, LinkGoToDefinitionState};
|
||||||
pub use multi_buffer::{
|
pub use multi_buffer::{
|
||||||
@ -54,6 +54,7 @@ pub use multi_buffer::{
|
|||||||
use multi_buffer::{MultiBufferChunks, ToOffsetUtf16};
|
use multi_buffer::{MultiBufferChunks, ToOffsetUtf16};
|
||||||
use ordered_float::OrderedFloat;
|
use ordered_float::OrderedFloat;
|
||||||
use project::{FormatTrigger, LocationLink, Project, ProjectPath, ProjectTransaction};
|
use project::{FormatTrigger, LocationLink, Project, ProjectPath, ProjectTransaction};
|
||||||
|
use rope::{offset_utf16::OffsetUtf16, point::Point};
|
||||||
use selections_collection::{resolve_multiple, MutableSelectionsCollection, SelectionsCollection};
|
use selections_collection::{resolve_multiple, MutableSelectionsCollection, SelectionsCollection};
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use settings::Settings;
|
use settings::Settings;
|
||||||
|
@ -11,9 +11,9 @@ use gpui::{
|
|||||||
use indoc::indoc;
|
use indoc::indoc;
|
||||||
use language::{FakeLspAdapter, LanguageConfig, LanguageRegistry};
|
use language::{FakeLspAdapter, LanguageConfig, LanguageRegistry};
|
||||||
use project::FakeFs;
|
use project::FakeFs;
|
||||||
|
use rope::point::Point;
|
||||||
use settings::EditorSettings;
|
use settings::EditorSettings;
|
||||||
use std::{cell::RefCell, rc::Rc, time::Instant};
|
use std::{cell::RefCell, rc::Rc, time::Instant};
|
||||||
use text::Point;
|
|
||||||
use unindent::Unindent;
|
use unindent::Unindent;
|
||||||
use util::{
|
use util::{
|
||||||
assert_set_eq,
|
assert_set_eq,
|
||||||
|
@ -35,8 +35,9 @@ use gpui::{
|
|||||||
WeakViewHandle,
|
WeakViewHandle,
|
||||||
};
|
};
|
||||||
use json::json;
|
use json::json;
|
||||||
use language::{Bias, DiagnosticSeverity, OffsetUtf16, Selection};
|
use language::{Bias, DiagnosticSeverity, Selection};
|
||||||
use project::ProjectPath;
|
use project::ProjectPath;
|
||||||
|
use rope::offset_utf16::OffsetUtf16;
|
||||||
use settings::{GitGutter, Settings};
|
use settings::{GitGutter, Settings};
|
||||||
use smallvec::SmallVec;
|
use smallvec::SmallVec;
|
||||||
use std::{
|
use std::{
|
||||||
|
@ -11,6 +11,7 @@ use gpui::{
|
|||||||
};
|
};
|
||||||
use language::{Bias, Buffer, File as _, OffsetRangeExt, SelectionGoal};
|
use language::{Bias, Buffer, File as _, OffsetRangeExt, SelectionGoal};
|
||||||
use project::{File, FormatTrigger, Project, ProjectEntryId, ProjectPath};
|
use project::{File, FormatTrigger, Project, ProjectEntryId, ProjectPath};
|
||||||
|
use rope::point::Point;
|
||||||
use rpc::proto::{self, update_view};
|
use rpc::proto::{self, update_view};
|
||||||
use settings::Settings;
|
use settings::Settings;
|
||||||
use smallvec::SmallVec;
|
use smallvec::SmallVec;
|
||||||
@ -21,7 +22,7 @@ use std::{
|
|||||||
ops::Range,
|
ops::Range,
|
||||||
path::{Path, PathBuf},
|
path::{Path, PathBuf},
|
||||||
};
|
};
|
||||||
use text::{Point, Selection};
|
use text::Selection;
|
||||||
use util::TryFutureExt;
|
use util::TryFutureExt;
|
||||||
use workspace::{
|
use workspace::{
|
||||||
searchable::{Direction, SearchEvent, SearchableItem, SearchableItemHandle},
|
searchable::{Direction, SearchEvent, SearchableItem, SearchableItemHandle},
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
|
use rope::point::Point;
|
||||||
|
|
||||||
use super::{Bias, DisplayPoint, DisplaySnapshot, SelectionGoal, ToDisplayPoint};
|
use super::{Bias, DisplayPoint, DisplaySnapshot, SelectionGoal, ToDisplayPoint};
|
||||||
use crate::{char_kind, CharKind, ToPoint};
|
use crate::{char_kind, CharKind, ToPoint};
|
||||||
use language::Point;
|
|
||||||
use std::ops::Range;
|
use std::ops::Range;
|
||||||
|
|
||||||
pub fn left(map: &DisplaySnapshot, mut point: DisplayPoint) -> DisplayPoint {
|
pub fn left(map: &DisplaySnapshot, mut point: DisplayPoint) -> DisplayPoint {
|
||||||
@ -273,7 +274,7 @@ pub fn surrounding_word(map: &DisplaySnapshot, position: DisplayPoint) -> Range<
|
|||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
use crate::{test::marked_display_snapshot, Buffer, DisplayMap, ExcerptRange, MultiBuffer};
|
use crate::{test::marked_display_snapshot, Buffer, DisplayMap, ExcerptRange, MultiBuffer};
|
||||||
use language::Point;
|
use rope::point::Point;
|
||||||
use settings::Settings;
|
use settings::Settings;
|
||||||
|
|
||||||
#[gpui::test]
|
#[gpui::test]
|
||||||
|
@ -12,6 +12,7 @@ use language::{
|
|||||||
DiagnosticEntry, Event, File, IndentSize, Language, OffsetRangeExt, Outline, OutlineItem,
|
DiagnosticEntry, Event, File, IndentSize, Language, OffsetRangeExt, Outline, OutlineItem,
|
||||||
Selection, ToOffset as _, ToOffsetUtf16 as _, ToPoint as _, ToPointUtf16 as _, TransactionId,
|
Selection, ToOffset as _, ToOffsetUtf16 as _, ToPoint as _, ToPointUtf16 as _, TransactionId,
|
||||||
};
|
};
|
||||||
|
use rope::{offset_utf16::OffsetUtf16, point::Point, point_utf16::PointUtf16, TextDimension};
|
||||||
use smallvec::SmallVec;
|
use smallvec::SmallVec;
|
||||||
use std::{
|
use std::{
|
||||||
borrow::Cow,
|
borrow::Cow,
|
||||||
@ -27,9 +28,8 @@ use std::{
|
|||||||
use sum_tree::{Bias, Cursor, SumTree};
|
use sum_tree::{Bias, Cursor, SumTree};
|
||||||
use text::{
|
use text::{
|
||||||
locator::Locator,
|
locator::Locator,
|
||||||
rope::TextDimension,
|
|
||||||
subscription::{Subscription, Topic},
|
subscription::{Subscription, Topic},
|
||||||
Edit, OffsetUtf16, Point, PointUtf16, TextSummary,
|
Edit, TextSummary,
|
||||||
};
|
};
|
||||||
use theme::SyntaxTheme;
|
use theme::SyntaxTheme;
|
||||||
use util::post_inc;
|
use util::post_inc;
|
||||||
@ -168,7 +168,7 @@ struct ExcerptChunks<'a> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
struct ExcerptBytes<'a> {
|
struct ExcerptBytes<'a> {
|
||||||
content_bytes: language::rope::Bytes<'a>,
|
content_bytes: rope::Bytes<'a>,
|
||||||
footer_height: usize,
|
footer_height: usize,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1412,7 +1412,7 @@ impl MultiBuffer {
|
|||||||
edit_count: usize,
|
edit_count: usize,
|
||||||
cx: &mut ModelContext<Self>,
|
cx: &mut ModelContext<Self>,
|
||||||
) {
|
) {
|
||||||
use text::RandomCharIter;
|
use util::RandomCharIter;
|
||||||
|
|
||||||
let snapshot = self.read(cx);
|
let snapshot = self.read(cx);
|
||||||
let mut edits: Vec<(Range<usize>, Arc<str>)> = Vec::new();
|
let mut edits: Vec<(Range<usize>, Arc<str>)> = Vec::new();
|
||||||
@ -1451,7 +1451,7 @@ impl MultiBuffer {
|
|||||||
) {
|
) {
|
||||||
use rand::prelude::*;
|
use rand::prelude::*;
|
||||||
use std::env;
|
use std::env;
|
||||||
use text::RandomCharIter;
|
use util::RandomCharIter;
|
||||||
|
|
||||||
let max_excerpts = env::var("MAX_EXCERPTS")
|
let max_excerpts = env::var("MAX_EXCERPTS")
|
||||||
.map(|i| i.parse().expect("invalid `MAX_EXCERPTS` variable"))
|
.map(|i| i.parse().expect("invalid `MAX_EXCERPTS` variable"))
|
||||||
@ -3337,7 +3337,7 @@ mod tests {
|
|||||||
use rand::prelude::*;
|
use rand::prelude::*;
|
||||||
use settings::Settings;
|
use settings::Settings;
|
||||||
use std::{env, rc::Rc};
|
use std::{env, rc::Rc};
|
||||||
use text::{Point, RandomCharIter};
|
|
||||||
use util::test::sample_text;
|
use util::test::sample_text;
|
||||||
|
|
||||||
#[gpui::test]
|
#[gpui::test]
|
||||||
@ -3955,7 +3955,9 @@ mod tests {
|
|||||||
}
|
}
|
||||||
_ => {
|
_ => {
|
||||||
let buffer_handle = if buffers.is_empty() || rng.gen_bool(0.4) {
|
let buffer_handle = if buffers.is_empty() || rng.gen_bool(0.4) {
|
||||||
let base_text = RandomCharIter::new(&mut rng).take(10).collect::<String>();
|
let base_text = util::RandomCharIter::new(&mut rng)
|
||||||
|
.take(10)
|
||||||
|
.collect::<String>();
|
||||||
buffers.push(cx.add_model(|cx| Buffer::new(0, base_text, cx)));
|
buffers.push(cx.add_model(|cx| Buffer::new(0, base_text, cx)));
|
||||||
buffers.last().unwrap()
|
buffers.last().unwrap()
|
||||||
} else {
|
} else {
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
use super::{ExcerptId, MultiBufferSnapshot, ToOffset, ToOffsetUtf16, ToPoint};
|
use super::{ExcerptId, MultiBufferSnapshot, ToOffset, ToOffsetUtf16, ToPoint};
|
||||||
|
use rope::{offset_utf16::OffsetUtf16, point::Point, TextDimension};
|
||||||
use std::{
|
use std::{
|
||||||
cmp::Ordering,
|
cmp::Ordering,
|
||||||
ops::{Range, Sub},
|
ops::{Range, Sub},
|
||||||
};
|
};
|
||||||
use sum_tree::Bias;
|
use sum_tree::Bias;
|
||||||
use text::{rope::TextDimension, OffsetUtf16, Point};
|
|
||||||
|
|
||||||
#[derive(Clone, Eq, PartialEq, Debug, Hash)]
|
#[derive(Clone, Eq, PartialEq, Debug, Hash)]
|
||||||
pub struct Anchor {
|
pub struct Anchor {
|
||||||
|
@ -8,7 +8,8 @@ use std::{
|
|||||||
use collections::HashMap;
|
use collections::HashMap;
|
||||||
use gpui::{AppContext, ModelHandle, MutableAppContext};
|
use gpui::{AppContext, ModelHandle, MutableAppContext};
|
||||||
use itertools::Itertools;
|
use itertools::Itertools;
|
||||||
use language::{rope::TextDimension, Bias, Point, Selection, SelectionGoal, ToPoint};
|
use language::{Bias, Selection, SelectionGoal, ToPoint};
|
||||||
|
use rope::{point::Point, TextDimension};
|
||||||
use util::post_inc;
|
use util::post_inc;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
|
@ -8,11 +8,23 @@ path = "src/fs.rs"
|
|||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
collections = { path = "../collections" }
|
collections = { path = "../collections" }
|
||||||
fsevent = { path = "../fsevent" }
|
gpui = { path = "../gpui" }
|
||||||
|
lsp = { path = "../lsp" }
|
||||||
|
rope = { path = "../rope" }
|
||||||
|
util = { path = "../util" }
|
||||||
anyhow = "1.0.57"
|
anyhow = "1.0.57"
|
||||||
async-trait = "0.1"
|
async-trait = "0.1"
|
||||||
futures = "0.3"
|
futures = "0.3"
|
||||||
|
fsevent = { path = "../fsevent" }
|
||||||
|
lazy_static = "1.4.0"
|
||||||
parking_lot = "0.11.1"
|
parking_lot = "0.11.1"
|
||||||
smol = "1.2.5"
|
smol = "1.2.5"
|
||||||
text = { path = "../text" }
|
regex = "1.5"
|
||||||
util = { path = "../util" }
|
git2 = { version = "0.15", default-features = false }
|
||||||
|
serde = { workspace = true }
|
||||||
|
serde_json = { workspace = true }
|
||||||
|
log = { version = "0.4.16", features = ["kv_unstable_serde"] }
|
||||||
|
libc = "0.2"
|
||||||
|
|
||||||
|
[features]
|
||||||
|
test-support = []
|
||||||
|
@ -3,8 +3,15 @@ pub mod repository;
|
|||||||
use anyhow::{anyhow, Result};
|
use anyhow::{anyhow, Result};
|
||||||
use fsevent::EventStream;
|
use fsevent::EventStream;
|
||||||
use futures::{future::BoxFuture, Stream, StreamExt};
|
use futures::{future::BoxFuture, Stream, StreamExt};
|
||||||
|
use git2::Repository as LibGitRepository;
|
||||||
|
use lazy_static::lazy_static;
|
||||||
use parking_lot::Mutex as SyncMutex;
|
use parking_lot::Mutex as SyncMutex;
|
||||||
|
use regex::Regex;
|
||||||
|
use repository::GitRepository;
|
||||||
|
use rope::Rope;
|
||||||
use smol::io::{AsyncReadExt, AsyncWriteExt};
|
use smol::io::{AsyncReadExt, AsyncWriteExt};
|
||||||
|
use std::borrow::Cow;
|
||||||
|
use std::cmp;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
use std::{
|
use std::{
|
||||||
io,
|
io,
|
||||||
@ -13,7 +20,6 @@ use std::{
|
|||||||
pin::Pin,
|
pin::Pin,
|
||||||
time::{Duration, SystemTime},
|
time::{Duration, SystemTime},
|
||||||
};
|
};
|
||||||
use text::Rope;
|
|
||||||
use util::ResultExt;
|
use util::ResultExt;
|
||||||
|
|
||||||
#[cfg(any(test, feature = "test-support"))]
|
#[cfg(any(test, feature = "test-support"))]
|
||||||
@ -21,10 +27,14 @@ use collections::{btree_map, BTreeMap};
|
|||||||
#[cfg(any(test, feature = "test-support"))]
|
#[cfg(any(test, feature = "test-support"))]
|
||||||
use futures::lock::Mutex;
|
use futures::lock::Mutex;
|
||||||
#[cfg(any(test, feature = "test-support"))]
|
#[cfg(any(test, feature = "test-support"))]
|
||||||
use git::repository::FakeGitRepositoryState;
|
use repository::FakeGitRepositoryState;
|
||||||
#[cfg(any(test, feature = "test-support"))]
|
#[cfg(any(test, feature = "test-support"))]
|
||||||
use std::sync::Weak;
|
use std::sync::Weak;
|
||||||
|
|
||||||
|
lazy_static! {
|
||||||
|
static ref CARRIAGE_RETURNS_REGEX: Regex = Regex::new("\r\n|\r").unwrap();
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Clone, Copy, Debug, PartialEq)]
|
#[derive(Clone, Copy, Debug, PartialEq)]
|
||||||
pub enum LineEnding {
|
pub enum LineEnding {
|
||||||
Unix,
|
Unix,
|
||||||
@ -72,7 +82,7 @@ impl LineEnding {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn normalize_arc(text: Arc<str>) -> Arc<str> {
|
pub fn normalize_arc(text: Arc<str>) -> Arc<str> {
|
||||||
if let Cow::Owned(replaced) = CARRIAGE_RETURNS_REGEX.replace_all(&text, "\n") {
|
if let Cow::Owned(replaced) = CARRIAGE_RETURNS_REGEX.replace_all(&text, "\n") {
|
||||||
replaced.into()
|
replaced.into()
|
||||||
} else {
|
} else {
|
||||||
@ -141,6 +151,33 @@ pub struct Metadata {
|
|||||||
pub is_dir: bool,
|
pub is_dir: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl From<lsp::CreateFileOptions> for CreateOptions {
|
||||||
|
fn from(options: lsp::CreateFileOptions) -> Self {
|
||||||
|
Self {
|
||||||
|
overwrite: options.overwrite.unwrap_or(false),
|
||||||
|
ignore_if_exists: options.ignore_if_exists.unwrap_or(false),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl From<lsp::RenameFileOptions> for RenameOptions {
|
||||||
|
fn from(options: lsp::RenameFileOptions) -> Self {
|
||||||
|
Self {
|
||||||
|
overwrite: options.overwrite.unwrap_or(false),
|
||||||
|
ignore_if_exists: options.ignore_if_exists.unwrap_or(false),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl From<lsp::DeleteFileOptions> for RemoveOptions {
|
||||||
|
fn from(options: lsp::DeleteFileOptions) -> Self {
|
||||||
|
Self {
|
||||||
|
recursive: options.recursive.unwrap_or(false),
|
||||||
|
ignore_if_not_exists: options.ignore_if_not_exists.unwrap_or(false),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pub struct RealFs;
|
pub struct RealFs;
|
||||||
|
|
||||||
#[async_trait::async_trait]
|
#[async_trait::async_trait]
|
||||||
@ -340,7 +377,7 @@ enum FakeFsEntry {
|
|||||||
inode: u64,
|
inode: u64,
|
||||||
mtime: SystemTime,
|
mtime: SystemTime,
|
||||||
entries: BTreeMap<String, Arc<Mutex<FakeFsEntry>>>,
|
entries: BTreeMap<String, Arc<Mutex<FakeFsEntry>>>,
|
||||||
git_repo_state: Option<Arc<SyncMutex<git::repository::FakeGitRepositoryState>>>,
|
git_repo_state: Option<Arc<SyncMutex<repository::FakeGitRepositoryState>>>,
|
||||||
},
|
},
|
||||||
Symlink {
|
Symlink {
|
||||||
target: PathBuf,
|
target: PathBuf,
|
||||||
@ -952,7 +989,7 @@ impl Fs for FakeFs {
|
|||||||
Arc::new(SyncMutex::new(FakeGitRepositoryState::default()))
|
Arc::new(SyncMutex::new(FakeGitRepositoryState::default()))
|
||||||
})
|
})
|
||||||
.clone();
|
.clone();
|
||||||
Some(git::repository::FakeGitRepository::open(state))
|
Some(repository::FakeGitRepository::open(state))
|
||||||
} else {
|
} else {
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
|
@ -9,7 +9,7 @@ path = "src/git.rs"
|
|||||||
[dependencies]
|
[dependencies]
|
||||||
anyhow = "1.0.38"
|
anyhow = "1.0.38"
|
||||||
clock = { path = "../clock" }
|
clock = { path = "../clock" }
|
||||||
git2 = { version = "0.15", default-features = false }
|
rope = { path = "../rope" }
|
||||||
lazy_static = "1.4.0"
|
lazy_static = "1.4.0"
|
||||||
sum_tree = { path = "../sum_tree" }
|
sum_tree = { path = "../sum_tree" }
|
||||||
text = { path = "../text" }
|
text = { path = "../text" }
|
||||||
@ -20,6 +20,7 @@ smol = "1.2"
|
|||||||
parking_lot = "0.11.1"
|
parking_lot = "0.11.1"
|
||||||
async-trait = "0.1"
|
async-trait = "0.1"
|
||||||
futures = "0.3"
|
futures = "0.3"
|
||||||
|
git2 = { version = "0.15", default-features = false }
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
unindent = "0.1.7"
|
unindent = "0.1.7"
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
use std::ops::Range;
|
use std::ops::Range;
|
||||||
|
|
||||||
|
use rope::point::Point;
|
||||||
use sum_tree::SumTree;
|
use sum_tree::SumTree;
|
||||||
use text::{Anchor, BufferSnapshot, OffsetRangeExt, Point};
|
use text::{Anchor, BufferSnapshot, OffsetRangeExt};
|
||||||
|
|
||||||
pub use git2 as libgit;
|
pub use git2 as libgit;
|
||||||
use libgit::{DiffLineType as GitDiffLineType, DiffOptions as GitOptions, Patch as GitPatch};
|
use libgit::{DiffLineType as GitDiffLineType, DiffOptions as GitOptions, Patch as GitPatch};
|
||||||
|
@ -4,7 +4,6 @@ pub use git2 as libgit;
|
|||||||
pub use lazy_static::lazy_static;
|
pub use lazy_static::lazy_static;
|
||||||
|
|
||||||
pub mod diff;
|
pub mod diff;
|
||||||
pub mod repository;
|
|
||||||
|
|
||||||
lazy_static! {
|
lazy_static! {
|
||||||
pub static ref DOT_GIT: &'static OsStr = OsStr::new(".git");
|
pub static ref DOT_GIT: &'static OsStr = OsStr::new(".git");
|
||||||
|
@ -13,5 +13,6 @@ gpui = { path = "../gpui" }
|
|||||||
menu = { path = "../menu" }
|
menu = { path = "../menu" }
|
||||||
settings = { path = "../settings" }
|
settings = { path = "../settings" }
|
||||||
text = { path = "../text" }
|
text = { path = "../text" }
|
||||||
|
rope = { path = "../rope" }
|
||||||
workspace = { path = "../workspace" }
|
workspace = { path = "../workspace" }
|
||||||
postage = { version = "0.4", features = ["futures-traits"] }
|
postage = { version = "0.4", features = ["futures-traits"] }
|
||||||
|
@ -4,8 +4,9 @@ use gpui::{
|
|||||||
MutableAppContext, RenderContext, View, ViewContext, ViewHandle,
|
MutableAppContext, RenderContext, View, ViewContext, ViewHandle,
|
||||||
};
|
};
|
||||||
use menu::{Cancel, Confirm};
|
use menu::{Cancel, Confirm};
|
||||||
|
use rope::point::Point;
|
||||||
use settings::Settings;
|
use settings::Settings;
|
||||||
use text::{Bias, Point};
|
use text::Bias;
|
||||||
use workspace::Workspace;
|
use workspace::Workspace;
|
||||||
|
|
||||||
actions!(go_to_line, [Toggle]);
|
actions!(go_to_line, [Toggle]);
|
||||||
|
@ -25,9 +25,11 @@ client = { path = "../client" }
|
|||||||
clock = { path = "../clock" }
|
clock = { path = "../clock" }
|
||||||
collections = { path = "../collections" }
|
collections = { path = "../collections" }
|
||||||
fuzzy = { path = "../fuzzy" }
|
fuzzy = { path = "../fuzzy" }
|
||||||
|
fs = { path = "../fs" }
|
||||||
git = { path = "../git" }
|
git = { path = "../git" }
|
||||||
gpui = { path = "../gpui" }
|
gpui = { path = "../gpui" }
|
||||||
lsp = { path = "../lsp" }
|
lsp = { path = "../lsp" }
|
||||||
|
rope = { path = "../rope" }
|
||||||
rpc = { path = "../rpc" }
|
rpc = { path = "../rpc" }
|
||||||
settings = { path = "../settings" }
|
settings = { path = "../settings" }
|
||||||
sum_tree = { path = "../sum_tree" }
|
sum_tree = { path = "../sum_tree" }
|
||||||
|
@ -13,9 +13,11 @@ use crate::{
|
|||||||
};
|
};
|
||||||
use anyhow::{anyhow, Result};
|
use anyhow::{anyhow, Result};
|
||||||
use clock::ReplicaId;
|
use clock::ReplicaId;
|
||||||
|
use fs::LineEnding;
|
||||||
use futures::FutureExt as _;
|
use futures::FutureExt as _;
|
||||||
use gpui::{fonts::HighlightStyle, AppContext, Entity, ModelContext, MutableAppContext, Task};
|
use gpui::{fonts::HighlightStyle, AppContext, Entity, ModelContext, MutableAppContext, Task};
|
||||||
use parking_lot::Mutex;
|
use parking_lot::Mutex;
|
||||||
|
use rope::point::Point;
|
||||||
use settings::Settings;
|
use settings::Settings;
|
||||||
use similar::{ChangeTag, TextDiff};
|
use similar::{ChangeTag, TextDiff};
|
||||||
use smol::future::yield_now;
|
use smol::future::yield_now;
|
||||||
@ -38,7 +40,7 @@ use sum_tree::TreeMap;
|
|||||||
use text::operation_queue::OperationQueue;
|
use text::operation_queue::OperationQueue;
|
||||||
pub use text::{Buffer as TextBuffer, BufferSnapshot as TextBufferSnapshot, Operation as _, *};
|
pub use text::{Buffer as TextBuffer, BufferSnapshot as TextBufferSnapshot, Operation as _, *};
|
||||||
use theme::SyntaxTheme;
|
use theme::SyntaxTheme;
|
||||||
use util::TryFutureExt as _;
|
use util::{RandomCharIter, TryFutureExt as _};
|
||||||
|
|
||||||
#[cfg(any(test, feature = "test-support"))]
|
#[cfg(any(test, feature = "test-support"))]
|
||||||
pub use {tree_sitter_rust, tree_sitter_typescript};
|
pub use {tree_sitter_rust, tree_sitter_typescript};
|
||||||
@ -368,7 +370,7 @@ impl Buffer {
|
|||||||
file,
|
file,
|
||||||
);
|
);
|
||||||
this.text.set_line_ending(proto::deserialize_line_ending(
|
this.text.set_line_ending(proto::deserialize_line_ending(
|
||||||
proto::LineEnding::from_i32(message.line_ending)
|
rpc::proto::LineEnding::from_i32(message.line_ending)
|
||||||
.ok_or_else(|| anyhow!("missing line_ending"))?,
|
.ok_or_else(|| anyhow!("missing line_ending"))?,
|
||||||
));
|
));
|
||||||
Ok(this)
|
Ok(this)
|
||||||
@ -1633,9 +1635,7 @@ impl Buffer {
|
|||||||
last_end = Some(range.end);
|
last_end = Some(range.end);
|
||||||
|
|
||||||
let new_text_len = rng.gen_range(0..10);
|
let new_text_len = rng.gen_range(0..10);
|
||||||
let new_text: String = crate::random_char_iter::RandomCharIter::new(&mut *rng)
|
let new_text: String = RandomCharIter::new(&mut *rng).take(new_text_len).collect();
|
||||||
.take(new_text_len)
|
|
||||||
.collect();
|
|
||||||
|
|
||||||
edits.push((range, new_text));
|
edits.push((range, new_text));
|
||||||
}
|
}
|
||||||
|
@ -1,9 +1,11 @@
|
|||||||
use super::*;
|
use super::*;
|
||||||
use clock::ReplicaId;
|
use clock::ReplicaId;
|
||||||
use collections::BTreeMap;
|
use collections::BTreeMap;
|
||||||
|
use fs::LineEnding;
|
||||||
use gpui::{ModelHandle, MutableAppContext};
|
use gpui::{ModelHandle, MutableAppContext};
|
||||||
use proto::deserialize_operation;
|
use proto::deserialize_operation;
|
||||||
use rand::prelude::*;
|
use rand::prelude::*;
|
||||||
|
use rope::point::Point;
|
||||||
use settings::Settings;
|
use settings::Settings;
|
||||||
use std::{
|
use std::{
|
||||||
cell::RefCell,
|
cell::RefCell,
|
||||||
@ -14,7 +16,7 @@ use std::{
|
|||||||
};
|
};
|
||||||
use text::network::Network;
|
use text::network::Network;
|
||||||
use unindent::Unindent as _;
|
use unindent::Unindent as _;
|
||||||
use util::{post_inc, test::marked_text_ranges};
|
use util::{post_inc, test::marked_text_ranges, RandomCharIter};
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
#[ctor::ctor]
|
#[ctor::ctor]
|
||||||
|
@ -1,12 +1,13 @@
|
|||||||
use crate::Diagnostic;
|
use crate::Diagnostic;
|
||||||
use collections::HashMap;
|
use collections::HashMap;
|
||||||
|
use rope::point_utf16::PointUtf16;
|
||||||
use std::{
|
use std::{
|
||||||
cmp::{Ordering, Reverse},
|
cmp::{Ordering, Reverse},
|
||||||
iter,
|
iter,
|
||||||
ops::Range,
|
ops::Range,
|
||||||
};
|
};
|
||||||
use sum_tree::{self, Bias, SumTree};
|
use sum_tree::{self, Bias, SumTree};
|
||||||
use text::{Anchor, FromAnchor, PointUtf16, ToOffset};
|
use text::{Anchor, FromAnchor, ToOffset};
|
||||||
|
|
||||||
#[derive(Clone, Debug, Default)]
|
#[derive(Clone, Debug, Default)]
|
||||||
pub struct DiagnosticSet {
|
pub struct DiagnosticSet {
|
||||||
|
@ -22,6 +22,7 @@ use lazy_static::lazy_static;
|
|||||||
use parking_lot::{Mutex, RwLock};
|
use parking_lot::{Mutex, RwLock};
|
||||||
use postage::watch;
|
use postage::watch;
|
||||||
use regex::Regex;
|
use regex::Regex;
|
||||||
|
use rope::point_utf16::PointUtf16;
|
||||||
use serde::{de, Deserialize, Deserializer};
|
use serde::{de, Deserialize, Deserializer};
|
||||||
use serde_json::Value;
|
use serde_json::Value;
|
||||||
use std::{
|
use std::{
|
||||||
|
@ -8,19 +8,19 @@ use rpc::proto;
|
|||||||
use std::{ops::Range, sync::Arc};
|
use std::{ops::Range, sync::Arc};
|
||||||
use text::*;
|
use text::*;
|
||||||
|
|
||||||
pub use proto::{BufferState, LineEnding, Operation, SelectionSet};
|
pub use proto::{BufferState, Operation, SelectionSet};
|
||||||
|
|
||||||
pub fn deserialize_line_ending(message: proto::LineEnding) -> text::LineEnding {
|
pub fn deserialize_line_ending(message: proto::LineEnding) -> fs::LineEnding {
|
||||||
match message {
|
match message {
|
||||||
LineEnding::Unix => text::LineEnding::Unix,
|
proto::LineEnding::Unix => fs::LineEnding::Unix,
|
||||||
LineEnding::Windows => text::LineEnding::Windows,
|
proto::LineEnding::Windows => fs::LineEnding::Windows,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn serialize_line_ending(message: text::LineEnding) -> proto::LineEnding {
|
pub fn serialize_line_ending(message: fs::LineEnding) -> proto::LineEnding {
|
||||||
match message {
|
match message {
|
||||||
text::LineEnding::Unix => proto::LineEnding::Unix,
|
fs::LineEnding::Unix => proto::LineEnding::Unix,
|
||||||
text::LineEnding::Windows => proto::LineEnding::Windows,
|
fs::LineEnding::Windows => proto::LineEnding::Windows,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
use crate::{Grammar, InjectionConfig, Language, LanguageRegistry};
|
use crate::{Grammar, InjectionConfig, Language, LanguageRegistry};
|
||||||
use lazy_static::lazy_static;
|
use lazy_static::lazy_static;
|
||||||
use parking_lot::Mutex;
|
use parking_lot::Mutex;
|
||||||
|
use rope::point::Point;
|
||||||
use std::{
|
use std::{
|
||||||
borrow::Cow,
|
borrow::Cow,
|
||||||
cell::RefCell,
|
cell::RefCell,
|
||||||
@ -10,7 +11,7 @@ use std::{
|
|||||||
sync::Arc,
|
sync::Arc,
|
||||||
};
|
};
|
||||||
use sum_tree::{Bias, SeekTarget, SumTree};
|
use sum_tree::{Bias, SeekTarget, SumTree};
|
||||||
use text::{rope, Anchor, BufferSnapshot, OffsetRangeExt, Point, Rope, ToOffset, ToPoint};
|
use text::{Anchor, BufferSnapshot, OffsetRangeExt, Rope, ToOffset, ToPoint};
|
||||||
use tree_sitter::{
|
use tree_sitter::{
|
||||||
Node, Parser, Query, QueryCapture, QueryCaptures, QueryCursor, QueryMatches, Tree,
|
Node, Parser, Query, QueryCapture, QueryCaptures, QueryCursor, QueryMatches, Tree,
|
||||||
};
|
};
|
||||||
@ -1242,7 +1243,7 @@ mod tests {
|
|||||||
use crate::LanguageConfig;
|
use crate::LanguageConfig;
|
||||||
use rand::rngs::StdRng;
|
use rand::rngs::StdRng;
|
||||||
use std::env;
|
use std::env;
|
||||||
use text::{Buffer, Point};
|
use text::Buffer;
|
||||||
use unindent::Unindent as _;
|
use unindent::Unindent as _;
|
||||||
use util::test::marked_text_ranges;
|
use util::test::marked_text_ranges;
|
||||||
|
|
||||||
|
@ -22,12 +22,14 @@ client = { path = "../client" }
|
|||||||
clock = { path = "../clock" }
|
clock = { path = "../clock" }
|
||||||
collections = { path = "../collections" }
|
collections = { path = "../collections" }
|
||||||
db = { path = "../db" }
|
db = { path = "../db" }
|
||||||
|
fs = { path = "../fs" }
|
||||||
fsevent = { path = "../fsevent" }
|
fsevent = { path = "../fsevent" }
|
||||||
fuzzy = { path = "../fuzzy" }
|
fuzzy = { path = "../fuzzy" }
|
||||||
git = { path = "../git" }
|
git = { path = "../git" }
|
||||||
gpui = { path = "../gpui" }
|
gpui = { path = "../gpui" }
|
||||||
language = { path = "../language" }
|
language = { path = "../language" }
|
||||||
lsp = { path = "../lsp" }
|
lsp = { path = "../lsp" }
|
||||||
|
rope = { path = "../rope" }
|
||||||
rpc = { path = "../rpc" }
|
rpc = { path = "../rpc" }
|
||||||
settings = { path = "../settings" }
|
settings = { path = "../settings" }
|
||||||
sum_tree = { path = "../sum_tree" }
|
sum_tree = { path = "../sum_tree" }
|
||||||
@ -38,7 +40,6 @@ async-trait = "0.1"
|
|||||||
futures = "0.3"
|
futures = "0.3"
|
||||||
ignore = "0.4"
|
ignore = "0.4"
|
||||||
lazy_static = "1.4.0"
|
lazy_static = "1.4.0"
|
||||||
libc = "0.2"
|
|
||||||
log = { version = "0.4.16", features = ["kv_unstable_serde"] }
|
log = { version = "0.4.16", features = ["kv_unstable_serde"] }
|
||||||
parking_lot = "0.11.1"
|
parking_lot = "0.11.1"
|
||||||
postage = { version = "0.4.1", features = ["futures-traits"] }
|
postage = { version = "0.4.1", features = ["futures-traits"] }
|
||||||
@ -58,6 +59,7 @@ rocksdb = "0.18"
|
|||||||
client = { path = "../client", features = ["test-support"] }
|
client = { path = "../client", features = ["test-support"] }
|
||||||
collections = { path = "../collections", features = ["test-support"] }
|
collections = { path = "../collections", features = ["test-support"] }
|
||||||
db = { path = "../db", features = ["test-support"] }
|
db = { path = "../db", features = ["test-support"] }
|
||||||
|
fs = { path = "../fs", features = ["test-support"] }
|
||||||
gpui = { path = "../gpui", features = ["test-support"] }
|
gpui = { path = "../gpui", features = ["test-support"] }
|
||||||
language = { path = "../language", features = ["test-support"] }
|
language = { path = "../language", features = ["test-support"] }
|
||||||
lsp = { path = "../lsp", features = ["test-support"] }
|
lsp = { path = "../lsp", features = ["test-support"] }
|
||||||
|
@ -8,10 +8,11 @@ use gpui::{AppContext, AsyncAppContext, ModelHandle};
|
|||||||
use language::{
|
use language::{
|
||||||
point_from_lsp, point_to_lsp,
|
point_from_lsp, point_to_lsp,
|
||||||
proto::{deserialize_anchor, deserialize_version, serialize_anchor, serialize_version},
|
proto::{deserialize_anchor, deserialize_version, serialize_anchor, serialize_version},
|
||||||
range_from_lsp, Anchor, Bias, Buffer, CachedLspAdapter, PointUtf16, ToPointUtf16,
|
range_from_lsp, Anchor, Bias, Buffer, CachedLspAdapter, ToPointUtf16,
|
||||||
};
|
};
|
||||||
use lsp::{DocumentHighlightKind, LanguageServer, ServerCapabilities};
|
use lsp::{DocumentHighlightKind, LanguageServer, ServerCapabilities};
|
||||||
use pulldown_cmark::{CodeBlockKind, Event, Options, Parser, Tag};
|
use pulldown_cmark::{CodeBlockKind, Event, Options, Parser, Tag};
|
||||||
|
use rope::point_utf16::PointUtf16;
|
||||||
use std::{cmp::Reverse, ops::Range, path::Path, sync::Arc};
|
use std::{cmp::Reverse, ops::Range, path::Path, sync::Arc};
|
||||||
|
|
||||||
#[async_trait(?Send)]
|
#[async_trait(?Send)]
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
pub mod fs;
|
|
||||||
mod ignore;
|
mod ignore;
|
||||||
mod lsp_command;
|
mod lsp_command;
|
||||||
pub mod search;
|
pub mod search;
|
||||||
@ -25,9 +24,8 @@ use language::{
|
|||||||
},
|
},
|
||||||
range_from_lsp, range_to_lsp, Anchor, Bias, Buffer, CachedLspAdapter, CharKind, CodeAction,
|
range_from_lsp, range_to_lsp, Anchor, Bias, Buffer, CachedLspAdapter, CharKind, CodeAction,
|
||||||
CodeLabel, Completion, Diagnostic, DiagnosticEntry, DiagnosticSet, Event as BufferEvent,
|
CodeLabel, Completion, Diagnostic, DiagnosticEntry, DiagnosticSet, Event as BufferEvent,
|
||||||
File as _, Language, LanguageRegistry, LanguageServerName, LineEnding, LocalFile,
|
File as _, Language, LanguageRegistry, LanguageServerName, LocalFile, OffsetRangeExt,
|
||||||
OffsetRangeExt, Operation, Patch, PointUtf16, TextBufferSnapshot, ToOffset, ToPointUtf16,
|
Operation, Patch, TextBufferSnapshot, ToOffset, ToPointUtf16, Transaction,
|
||||||
Transaction,
|
|
||||||
};
|
};
|
||||||
use lsp::{
|
use lsp::{
|
||||||
DiagnosticSeverity, DiagnosticTag, DocumentHighlightKind, LanguageServer, LanguageString,
|
DiagnosticSeverity, DiagnosticTag, DocumentHighlightKind, LanguageServer, LanguageString,
|
||||||
@ -37,6 +35,7 @@ use lsp_command::*;
|
|||||||
use parking_lot::Mutex;
|
use parking_lot::Mutex;
|
||||||
use postage::watch;
|
use postage::watch;
|
||||||
use rand::prelude::*;
|
use rand::prelude::*;
|
||||||
|
use rope::point_utf16::PointUtf16;
|
||||||
use search::SearchQuery;
|
use search::SearchQuery;
|
||||||
use serde::Serialize;
|
use serde::Serialize;
|
||||||
use settings::{FormatOnSave, Formatter, Settings};
|
use settings::{FormatOnSave, Formatter, Settings};
|
||||||
@ -6019,33 +6018,6 @@ impl<P: AsRef<Path>> From<(WorktreeId, P)> for ProjectPath {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<lsp::CreateFileOptions> for fs::CreateOptions {
|
|
||||||
fn from(options: lsp::CreateFileOptions) -> Self {
|
|
||||||
Self {
|
|
||||||
overwrite: options.overwrite.unwrap_or(false),
|
|
||||||
ignore_if_exists: options.ignore_if_exists.unwrap_or(false),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl From<lsp::RenameFileOptions> for fs::RenameOptions {
|
|
||||||
fn from(options: lsp::RenameFileOptions) -> Self {
|
|
||||||
Self {
|
|
||||||
overwrite: options.overwrite.unwrap_or(false),
|
|
||||||
ignore_if_exists: options.ignore_if_exists.unwrap_or(false),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl From<lsp::DeleteFileOptions> for fs::RemoveOptions {
|
|
||||||
fn from(options: lsp::DeleteFileOptions) -> Self {
|
|
||||||
Self {
|
|
||||||
recursive: options.recursive.unwrap_or(false),
|
|
||||||
ignore_if_not_exists: options.ignore_if_not_exists.unwrap_or(false),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn serialize_symbol(symbol: &Symbol) -> proto::Symbol {
|
fn serialize_symbol(symbol: &Symbol) -> proto::Symbol {
|
||||||
proto::Symbol {
|
proto::Symbol {
|
||||||
language_server_name: symbol.language_server_name.0.to_string(),
|
language_server_name: symbol.language_server_name.0.to_string(),
|
||||||
|
@ -1,12 +1,14 @@
|
|||||||
use crate::{worktree::WorktreeHandle, Event, *};
|
use crate::{worktree::WorktreeHandle, Event, *};
|
||||||
use fs::RealFs;
|
use fs::LineEnding;
|
||||||
|
use fs::{FakeFs, RealFs};
|
||||||
use futures::{future, StreamExt};
|
use futures::{future, StreamExt};
|
||||||
use gpui::{executor::Deterministic, test::subscribe};
|
use gpui::{executor::Deterministic, test::subscribe};
|
||||||
use language::{
|
use language::{
|
||||||
tree_sitter_rust, tree_sitter_typescript, Diagnostic, FakeLspAdapter, LanguageConfig,
|
tree_sitter_rust, tree_sitter_typescript, Diagnostic, FakeLspAdapter, LanguageConfig,
|
||||||
LineEnding, OffsetRangeExt, Point, ToPoint,
|
OffsetRangeExt, ToPoint,
|
||||||
};
|
};
|
||||||
use lsp::Url;
|
use lsp::Url;
|
||||||
|
use rope::point::Point;
|
||||||
use serde_json::json;
|
use serde_json::json;
|
||||||
use std::{cell::RefCell, os::unix, rc::Rc, task::Poll};
|
use std::{cell::RefCell, os::unix, rc::Rc, task::Poll};
|
||||||
use unindent::Unindent as _;
|
use unindent::Unindent as _;
|
||||||
|
@ -1,14 +1,12 @@
|
|||||||
use super::{
|
use super::{ignore::IgnoreStack, DiagnosticSummary};
|
||||||
fs::{self, Fs},
|
|
||||||
ignore::IgnoreStack,
|
|
||||||
DiagnosticSummary,
|
|
||||||
};
|
|
||||||
use crate::{copy_recursive, ProjectEntryId, RemoveOptions};
|
use crate::{copy_recursive, ProjectEntryId, RemoveOptions};
|
||||||
use ::ignore::gitignore::{Gitignore, GitignoreBuilder};
|
use ::ignore::gitignore::{Gitignore, GitignoreBuilder};
|
||||||
use anyhow::{anyhow, Context, Result};
|
use anyhow::{anyhow, Context, Result};
|
||||||
use client::{proto, Client};
|
use client::{proto, Client};
|
||||||
use clock::ReplicaId;
|
use clock::ReplicaId;
|
||||||
use collections::{HashMap, VecDeque};
|
use collections::{HashMap, VecDeque};
|
||||||
|
use fs::LineEnding;
|
||||||
|
use fs::{repository::GitRepository, Fs};
|
||||||
use futures::{
|
use futures::{
|
||||||
channel::{
|
channel::{
|
||||||
mpsc::{self, UnboundedSender},
|
mpsc::{self, UnboundedSender},
|
||||||
@ -17,7 +15,6 @@ use futures::{
|
|||||||
Stream, StreamExt,
|
Stream, StreamExt,
|
||||||
};
|
};
|
||||||
use fuzzy::CharBag;
|
use fuzzy::CharBag;
|
||||||
use git::repository::GitRepository;
|
|
||||||
use git::{DOT_GIT, GITIGNORE};
|
use git::{DOT_GIT, GITIGNORE};
|
||||||
use gpui::{
|
use gpui::{
|
||||||
executor, AppContext, AsyncAppContext, Entity, ModelContext, ModelHandle, MutableAppContext,
|
executor, AppContext, AsyncAppContext, Entity, ModelContext, ModelHandle, MutableAppContext,
|
||||||
@ -25,13 +22,14 @@ use gpui::{
|
|||||||
};
|
};
|
||||||
use language::{
|
use language::{
|
||||||
proto::{deserialize_version, serialize_line_ending, serialize_version},
|
proto::{deserialize_version, serialize_line_ending, serialize_version},
|
||||||
Buffer, DiagnosticEntry, LineEnding, PointUtf16, Rope,
|
Buffer, DiagnosticEntry, Rope,
|
||||||
};
|
};
|
||||||
use parking_lot::Mutex;
|
use parking_lot::Mutex;
|
||||||
use postage::{
|
use postage::{
|
||||||
prelude::{Sink as _, Stream as _},
|
prelude::{Sink as _, Stream as _},
|
||||||
watch,
|
watch,
|
||||||
};
|
};
|
||||||
|
use rope::point_utf16::PointUtf16;
|
||||||
|
|
||||||
use smol::channel::{self, Sender};
|
use smol::channel::{self, Sender};
|
||||||
use std::{
|
use std::{
|
||||||
@ -2970,11 +2968,10 @@ async fn send_worktree_update(client: &Arc<Client>, update: proto::UpdateWorktre
|
|||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
use crate::fs::FakeFs;
|
|
||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
use client::test::FakeHttpClient;
|
use client::test::FakeHttpClient;
|
||||||
use fs::RealFs;
|
use fs::repository::FakeGitRepository;
|
||||||
use git::repository::FakeGitRepository;
|
use fs::{FakeFs, RealFs};
|
||||||
use gpui::{executor::Deterministic, TestAppContext};
|
use gpui::{executor::Deterministic, TestAppContext};
|
||||||
use rand::prelude::*;
|
use rand::prelude::*;
|
||||||
use serde_json::json;
|
use serde_json::json;
|
||||||
|
20
crates/rope/Cargo.toml
Normal file
20
crates/rope/Cargo.toml
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
[package]
|
||||||
|
name = "rope"
|
||||||
|
version = "0.1.0"
|
||||||
|
edition = "2021"
|
||||||
|
|
||||||
|
[lib]
|
||||||
|
path = "src/rope.rs"
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
|
bromberg_sl2 = "0.6"
|
||||||
|
smallvec = { version = "1.6", features = ["union"] }
|
||||||
|
sum_tree = { path = "../sum_tree" }
|
||||||
|
arrayvec = "0.7.1"
|
||||||
|
log = { version = "0.4.16", features = ["kv_unstable_serde"] }
|
||||||
|
|
||||||
|
|
||||||
|
[dev-dependencies]
|
||||||
|
rand = "0.8.3"
|
||||||
|
util = { path = "../util", features = ["test-support"] }
|
||||||
|
gpui = { path = "../gpui", features = ["test-support"] }
|
@ -1,7 +1,12 @@
|
|||||||
use super::Point;
|
pub mod offset_utf16;
|
||||||
use crate::{OffsetUtf16, PointUtf16};
|
pub mod point;
|
||||||
|
pub mod point_utf16;
|
||||||
|
|
||||||
use arrayvec::ArrayString;
|
use arrayvec::ArrayString;
|
||||||
use bromberg_sl2::{DigestString, HashMatrix};
|
use bromberg_sl2::{DigestString, HashMatrix};
|
||||||
|
use offset_utf16::OffsetUtf16;
|
||||||
|
use point::Point;
|
||||||
|
use point_utf16::PointUtf16;
|
||||||
use smallvec::SmallVec;
|
use smallvec::SmallVec;
|
||||||
use std::{cmp, fmt, io, mem, ops::Range, str};
|
use std::{cmp, fmt, io, mem, ops::Range, str};
|
||||||
use sum_tree::{Bias, Dimension, SumTree};
|
use sum_tree::{Bias, Dimension, SumTree};
|
||||||
@ -1073,9 +1078,9 @@ fn find_split_ix(text: &str) -> usize {
|
|||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
use crate::random_char_iter::RandomCharIter;
|
|
||||||
use rand::prelude::*;
|
use rand::prelude::*;
|
||||||
use std::{cmp::Ordering, env, io::Read};
|
use std::{cmp::Ordering, env, io::Read};
|
||||||
|
use util::RandomCharIter;
|
||||||
use Bias::{Left, Right};
|
use Bias::{Left, Right};
|
||||||
|
|
||||||
#[test]
|
#[test]
|
@ -14,23 +14,23 @@ test-support = ["rand"]
|
|||||||
clock = { path = "../clock" }
|
clock = { path = "../clock" }
|
||||||
collections = { path = "../collections" }
|
collections = { path = "../collections" }
|
||||||
fs = { path = "../fs" }
|
fs = { path = "../fs" }
|
||||||
|
rope = { path = "../rope" }
|
||||||
sum_tree = { path = "../sum_tree" }
|
sum_tree = { path = "../sum_tree" }
|
||||||
anyhow = "1.0.38"
|
anyhow = "1.0.38"
|
||||||
arrayvec = "0.7.1"
|
|
||||||
digest = { version = "0.9", features = ["std"] }
|
digest = { version = "0.9", features = ["std"] }
|
||||||
bromberg_sl2 = "0.6"
|
|
||||||
lazy_static = "1.4"
|
lazy_static = "1.4"
|
||||||
log = { version = "0.4.16", features = ["kv_unstable_serde"] }
|
log = { version = "0.4.16", features = ["kv_unstable_serde"] }
|
||||||
parking_lot = "0.11"
|
parking_lot = "0.11"
|
||||||
postage = { version = "0.4.1", features = ["futures-traits"] }
|
postage = { version = "0.4.1", features = ["futures-traits"] }
|
||||||
rand = { version = "0.8.3", optional = true }
|
rand = { version = "0.8.3", optional = true }
|
||||||
regex = "1.5"
|
|
||||||
smallvec = { version = "1.6", features = ["union"] }
|
smallvec = { version = "1.6", features = ["union"] }
|
||||||
|
util = { path = "../util" }
|
||||||
|
regex = "1.5"
|
||||||
|
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
collections = { path = "../collections", features = ["test-support"] }
|
collections = { path = "../collections", features = ["test-support"] }
|
||||||
gpui = { path = "../gpui", features = ["test-support"] }
|
gpui = { path = "../gpui", features = ["test-support"] }
|
||||||
util = { path = "../util", features = ["test-support"] }
|
|
||||||
ctor = "0.1"
|
ctor = "0.1"
|
||||||
env_logger = "0.9"
|
env_logger = "0.9"
|
||||||
rand = "0.8.3"
|
rand = "0.8.3"
|
||||||
|
@ -1,9 +1,10 @@
|
|||||||
use super::{Point, ToOffset};
|
|
||||||
use crate::{rope::TextDimension, BufferSnapshot, PointUtf16, ToPoint, ToPointUtf16};
|
|
||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
|
use rope::{point::Point, point_utf16::PointUtf16, TextDimension};
|
||||||
use std::{cmp::Ordering, fmt::Debug, ops::Range};
|
use std::{cmp::Ordering, fmt::Debug, ops::Range};
|
||||||
use sum_tree::Bias;
|
use sum_tree::Bias;
|
||||||
|
|
||||||
|
use crate::{BufferSnapshot, ToOffset, ToPoint, ToPointUtf16};
|
||||||
|
|
||||||
#[derive(Copy, Clone, Eq, PartialEq, Debug, Hash, Default)]
|
#[derive(Copy, Clone, Eq, PartialEq, Debug, Hash, Default)]
|
||||||
pub struct Anchor {
|
pub struct Anchor {
|
||||||
pub timestamp: clock::Local,
|
pub timestamp: clock::Local,
|
||||||
|
@ -1,36 +0,0 @@
|
|||||||
use rand::prelude::*;
|
|
||||||
|
|
||||||
pub struct RandomCharIter<T: Rng>(T);
|
|
||||||
|
|
||||||
impl<T: Rng> RandomCharIter<T> {
|
|
||||||
pub fn new(rng: T) -> Self {
|
|
||||||
Self(rng)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<T: Rng> Iterator for RandomCharIter<T> {
|
|
||||||
type Item = char;
|
|
||||||
|
|
||||||
fn next(&mut self) -> Option<Self::Item> {
|
|
||||||
if std::env::var("SIMPLE_TEXT").map_or(false, |v| !v.is_empty()) {
|
|
||||||
return if self.0.gen_range(0..100) < 5 {
|
|
||||||
Some('\n')
|
|
||||||
} else {
|
|
||||||
Some(self.0.gen_range(b'a'..b'z' + 1).into())
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
match self.0.gen_range(0..100) {
|
|
||||||
// whitespace
|
|
||||||
0..=19 => [' ', '\n', '\r', '\t'].choose(&mut self.0).copied(),
|
|
||||||
// two-byte greek letters
|
|
||||||
20..=32 => char::from_u32(self.0.gen_range(('α' as u32)..('ω' as u32 + 1))),
|
|
||||||
// // three-byte characters
|
|
||||||
33..=45 => ['✋', '✅', '❌', '❎', '⭐'].choose(&mut self.0).copied(),
|
|
||||||
// // four-byte characters
|
|
||||||
46..=58 => ['🍐', '🏀', '🍗', '🎉'].choose(&mut self.0).copied(),
|
|
||||||
// ascii letters
|
|
||||||
_ => Some(self.0.gen_range(b'a'..b'z' + 1).into()),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,5 +1,7 @@
|
|||||||
use crate::Anchor;
|
use rope::TextDimension;
|
||||||
use crate::{rope::TextDimension, BufferSnapshot};
|
|
||||||
|
use crate::{Anchor, BufferSnapshot};
|
||||||
|
|
||||||
use std::cmp::Ordering;
|
use std::cmp::Ordering;
|
||||||
use std::ops::Range;
|
use std::ops::Range;
|
||||||
|
|
||||||
|
@ -2,14 +2,8 @@ mod anchor;
|
|||||||
pub mod locator;
|
pub mod locator;
|
||||||
#[cfg(any(test, feature = "test-support"))]
|
#[cfg(any(test, feature = "test-support"))]
|
||||||
pub mod network;
|
pub mod network;
|
||||||
mod offset_utf16;
|
|
||||||
pub mod operation_queue;
|
pub mod operation_queue;
|
||||||
mod patch;
|
mod patch;
|
||||||
mod point;
|
|
||||||
mod point_utf16;
|
|
||||||
#[cfg(any(test, feature = "test-support"))]
|
|
||||||
pub mod random_char_iter;
|
|
||||||
pub mod rope;
|
|
||||||
mod selection;
|
mod selection;
|
||||||
pub mod subscription;
|
pub mod subscription;
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
@ -20,22 +14,15 @@ pub use anchor::*;
|
|||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
use clock::ReplicaId;
|
use clock::ReplicaId;
|
||||||
use collections::{HashMap, HashSet};
|
use collections::{HashMap, HashSet};
|
||||||
use lazy_static::lazy_static;
|
use fs::LineEnding;
|
||||||
use locator::Locator;
|
use locator::Locator;
|
||||||
pub use offset_utf16::*;
|
|
||||||
use operation_queue::OperationQueue;
|
use operation_queue::OperationQueue;
|
||||||
pub use patch::Patch;
|
pub use patch::Patch;
|
||||||
pub use point::*;
|
|
||||||
pub use point_utf16::*;
|
|
||||||
use postage::{barrier, oneshot, prelude::*};
|
use postage::{barrier, oneshot, prelude::*};
|
||||||
#[cfg(any(test, feature = "test-support"))]
|
use rope::{offset_utf16::OffsetUtf16, point::Point, point_utf16::PointUtf16, TextDimension};
|
||||||
pub use random_char_iter::*;
|
|
||||||
use regex::Regex;
|
|
||||||
use rope::TextDimension;
|
|
||||||
pub use rope::{Chunks, Rope, TextSummary};
|
pub use rope::{Chunks, Rope, TextSummary};
|
||||||
pub use selection::*;
|
pub use selection::*;
|
||||||
use std::{
|
use std::{
|
||||||
borrow::Cow,
|
|
||||||
cmp::{self, Ordering, Reverse},
|
cmp::{self, Ordering, Reverse},
|
||||||
future::Future,
|
future::Future,
|
||||||
iter::Iterator,
|
iter::Iterator,
|
||||||
@ -49,9 +36,8 @@ pub use sum_tree::Bias;
|
|||||||
use sum_tree::{FilterCursor, SumTree, TreeMap};
|
use sum_tree::{FilterCursor, SumTree, TreeMap};
|
||||||
use undo_map::UndoMap;
|
use undo_map::UndoMap;
|
||||||
|
|
||||||
lazy_static! {
|
#[cfg(any(test, feature = "test-support"))]
|
||||||
static ref CARRIAGE_RETURNS_REGEX: Regex = Regex::new("\r\n|\r").unwrap();
|
use util::RandomCharIter;
|
||||||
}
|
|
||||||
|
|
||||||
pub type TransactionId = clock::Local;
|
pub type TransactionId = clock::Local;
|
||||||
|
|
||||||
@ -1458,9 +1444,7 @@ impl Buffer {
|
|||||||
last_end = Some(range.end);
|
last_end = Some(range.end);
|
||||||
|
|
||||||
let new_text_len = rng.gen_range(0..10);
|
let new_text_len = rng.gen_range(0..10);
|
||||||
let new_text: String = crate::random_char_iter::RandomCharIter::new(&mut *rng)
|
let new_text: String = RandomCharIter::new(&mut *rng).take(new_text_len).collect();
|
||||||
.take(new_text_len)
|
|
||||||
.collect();
|
|
||||||
|
|
||||||
edits.push((range, new_text.into()));
|
edits.push((range, new_text.into()));
|
||||||
}
|
}
|
||||||
|
@ -7,21 +7,20 @@ edition = "2021"
|
|||||||
doctest = false
|
doctest = false
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
test-support = ["rand", "serde_json", "tempdir", "git2"]
|
test-support = ["serde_json", "tempdir", "git2"]
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
anyhow = "1.0.38"
|
anyhow = "1.0.38"
|
||||||
futures = "0.3"
|
futures = "0.3"
|
||||||
log = { version = "0.4.16", features = ["kv_unstable_serde"] }
|
log = { version = "0.4.16", features = ["kv_unstable_serde"] }
|
||||||
lazy_static = "1.4.0"
|
lazy_static = "1.4.0"
|
||||||
rand = { version = "0.8", optional = true }
|
rand = { workspace = true }
|
||||||
tempdir = { version = "0.3.7", optional = true }
|
tempdir = { version = "0.3.7", optional = true }
|
||||||
serde_json = { version = "1.0", features = ["preserve_order"], optional = true }
|
serde_json = { version = "1.0", features = ["preserve_order"], optional = true }
|
||||||
git2 = { version = "0.15", default-features = false, optional = true }
|
git2 = { version = "0.15", default-features = false, optional = true }
|
||||||
|
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
rand = { version = "0.8" }
|
|
||||||
tempdir = { version = "0.3.7" }
|
tempdir = { version = "0.3.7" }
|
||||||
serde_json = { version = "1.0", features = ["preserve_order"] }
|
serde_json = { version = "1.0", features = ["preserve_order"] }
|
||||||
git2 = { version = "0.15", default-features = false }
|
git2 = { version = "0.15", default-features = false }
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
pub mod test;
|
pub mod test;
|
||||||
|
|
||||||
use futures::Future;
|
use futures::Future;
|
||||||
|
use rand::{seq::SliceRandom, Rng};
|
||||||
use std::{
|
use std::{
|
||||||
cmp::Ordering,
|
cmp::Ordering,
|
||||||
ops::AddAssign,
|
ops::AddAssign,
|
||||||
@ -155,6 +156,41 @@ pub fn defer<F: FnOnce()>(f: F) -> impl Drop {
|
|||||||
Defer(Some(f))
|
Defer(Some(f))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub struct RandomCharIter<T: Rng>(T);
|
||||||
|
|
||||||
|
impl<T: Rng> RandomCharIter<T> {
|
||||||
|
pub fn new(rng: T) -> Self {
|
||||||
|
Self(rng)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<T: Rng> Iterator for RandomCharIter<T> {
|
||||||
|
type Item = char;
|
||||||
|
|
||||||
|
fn next(&mut self) -> Option<Self::Item> {
|
||||||
|
if std::env::var("SIMPLE_TEXT").map_or(false, |v| !v.is_empty()) {
|
||||||
|
return if self.0.gen_range(0..100) < 5 {
|
||||||
|
Some('\n')
|
||||||
|
} else {
|
||||||
|
Some(self.0.gen_range(b'a'..b'z' + 1).into())
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
match self.0.gen_range(0..100) {
|
||||||
|
// whitespace
|
||||||
|
0..=19 => [' ', '\n', '\r', '\t'].choose(&mut self.0).copied(),
|
||||||
|
// two-byte greek letters
|
||||||
|
20..=32 => char::from_u32(self.0.gen_range(('α' as u32)..('ω' as u32 + 1))),
|
||||||
|
// // three-byte characters
|
||||||
|
33..=45 => ['✋', '✅', '❌', '❎', '⭐'].choose(&mut self.0).copied(),
|
||||||
|
// // four-byte characters
|
||||||
|
46..=58 => ['🍐', '🏀', '🍗', '🎉'].choose(&mut self.0).copied(),
|
||||||
|
// ascii letters
|
||||||
|
_ => Some(self.0.gen_range(b'a'..b'z' + 1).into()),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
|
@ -14,6 +14,7 @@ command_palette = { path = "../command_palette" }
|
|||||||
editor = { path = "../editor" }
|
editor = { path = "../editor" }
|
||||||
gpui = { path = "../gpui" }
|
gpui = { path = "../gpui" }
|
||||||
language = { path = "../language" }
|
language = { path = "../language" }
|
||||||
|
rope = { path = "../rope" }
|
||||||
search = { path = "../search" }
|
search = { path = "../search" }
|
||||||
serde = { version = "1.0", features = ["derive", "rc"] }
|
serde = { version = "1.0", features = ["derive", "rc"] }
|
||||||
settings = { path = "../settings" }
|
settings = { path = "../settings" }
|
||||||
|
@ -13,7 +13,8 @@ use change::init as change_init;
|
|||||||
use collections::HashSet;
|
use collections::HashSet;
|
||||||
use editor::{Autoscroll, Bias, ClipboardSelection, DisplayPoint};
|
use editor::{Autoscroll, Bias, ClipboardSelection, DisplayPoint};
|
||||||
use gpui::{actions, MutableAppContext, ViewContext};
|
use gpui::{actions, MutableAppContext, ViewContext};
|
||||||
use language::{AutoindentMode, Point, SelectionGoal};
|
use language::{AutoindentMode, SelectionGoal};
|
||||||
|
use rope::point::Point;
|
||||||
use workspace::Workspace;
|
use workspace::Workspace;
|
||||||
|
|
||||||
use self::{change::change_over, delete::delete_over, yank::yank_over};
|
use self::{change::change_over, delete::delete_over, yank::yank_over};
|
||||||
|
@ -21,6 +21,7 @@ client = { path = "../client" }
|
|||||||
collections = { path = "../collections" }
|
collections = { path = "../collections" }
|
||||||
context_menu = { path = "../context_menu" }
|
context_menu = { path = "../context_menu" }
|
||||||
drag_and_drop = { path = "../drag_and_drop" }
|
drag_and_drop = { path = "../drag_and_drop" }
|
||||||
|
fs = { path = "../fs" }
|
||||||
gpui = { path = "../gpui" }
|
gpui = { path = "../gpui" }
|
||||||
language = { path = "../language" }
|
language = { path = "../language" }
|
||||||
menu = { path = "../menu" }
|
menu = { path = "../menu" }
|
||||||
|
@ -32,7 +32,8 @@ use log::{error, warn};
|
|||||||
pub use pane::*;
|
pub use pane::*;
|
||||||
pub use pane_group::*;
|
pub use pane_group::*;
|
||||||
use postage::prelude::Stream;
|
use postage::prelude::Stream;
|
||||||
use project::{fs, Fs, Project, ProjectEntryId, ProjectPath, ProjectStore, Worktree, WorktreeId};
|
use fs::{self, Fs};
|
||||||
|
use project::{Project, ProjectEntryId, ProjectPath, ProjectStore, Worktree, WorktreeId};
|
||||||
use searchable::SearchableItemHandle;
|
use searchable::SearchableItemHandle;
|
||||||
use serde::Deserialize;
|
use serde::Deserialize;
|
||||||
use settings::{Autosave, DockAnchor, Settings};
|
use settings::{Autosave, DockAnchor, Settings};
|
||||||
|
@ -32,6 +32,7 @@ diagnostics = { path = "../diagnostics" }
|
|||||||
editor = { path = "../editor" }
|
editor = { path = "../editor" }
|
||||||
file_finder = { path = "../file_finder" }
|
file_finder = { path = "../file_finder" }
|
||||||
search = { path = "../search" }
|
search = { path = "../search" }
|
||||||
|
fs = { path = "../fs" }
|
||||||
fsevent = { path = "../fsevent" }
|
fsevent = { path = "../fsevent" }
|
||||||
fuzzy = { path = "../fuzzy" }
|
fuzzy = { path = "../fuzzy" }
|
||||||
go_to_line = { path = "../go_to_line" }
|
go_to_line = { path = "../go_to_line" }
|
||||||
|
@ -14,7 +14,6 @@ use client::{
|
|||||||
http::{self, HttpClient},
|
http::{self, HttpClient},
|
||||||
UserStore, ZED_SECRET_CLIENT_TOKEN,
|
UserStore, ZED_SECRET_CLIENT_TOKEN,
|
||||||
};
|
};
|
||||||
use fs::OpenOptions;
|
|
||||||
use futures::{
|
use futures::{
|
||||||
channel::{mpsc, oneshot},
|
channel::{mpsc, oneshot},
|
||||||
FutureExt, SinkExt, StreamExt,
|
FutureExt, SinkExt, StreamExt,
|
||||||
@ -28,16 +27,16 @@ use project::{Fs, ProjectStore};
|
|||||||
use serde_json::json;
|
use serde_json::json;
|
||||||
use settings::{self, KeymapFileContent, Settings, SettingsFileContent, WorkingDirectory};
|
use settings::{self, KeymapFileContent, Settings, SettingsFileContent, WorkingDirectory};
|
||||||
use smol::process::Command;
|
use smol::process::Command;
|
||||||
use std::{env, ffi::OsStr, fs, panic, path::PathBuf, sync::Arc, thread, time::Duration};
|
use std::fs::OpenOptions;
|
||||||
|
use std::{env, ffi::OsStr, panic, path::PathBuf, sync::Arc, thread, time::Duration};
|
||||||
use terminal::terminal_container_view::{get_working_directory, TerminalContainer};
|
use terminal::terminal_container_view::{get_working_directory, TerminalContainer};
|
||||||
|
|
||||||
|
use fs::RealFs;
|
||||||
use theme::ThemeRegistry;
|
use theme::ThemeRegistry;
|
||||||
use util::{ResultExt, TryFutureExt};
|
use util::{ResultExt, TryFutureExt};
|
||||||
use workspace::{self, AppState, ItemHandle, NewFile, OpenPaths, Workspace};
|
use workspace::{self, AppState, ItemHandle, NewFile, OpenPaths, Workspace};
|
||||||
use zed::{
|
use zed::{
|
||||||
self, build_window_options,
|
self, build_window_options, initialize_workspace, languages, menus,
|
||||||
fs::RealFs,
|
|
||||||
initialize_workspace, languages, menus,
|
|
||||||
settings_file::{watch_keymap_file, watch_settings_file, WatchedJsonFile},
|
settings_file::{watch_keymap_file, watch_settings_file, WatchedJsonFile},
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -200,23 +199,23 @@ fn main() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn init_paths() {
|
fn init_paths() {
|
||||||
fs::create_dir_all(&*zed::paths::CONFIG_DIR).expect("could not create config path");
|
std::fs::create_dir_all(&*zed::paths::CONFIG_DIR).expect("could not create config path");
|
||||||
fs::create_dir_all(&*zed::paths::LANGUAGES_DIR).expect("could not create languages path");
|
std::fs::create_dir_all(&*zed::paths::LANGUAGES_DIR).expect("could not create languages path");
|
||||||
fs::create_dir_all(&*zed::paths::DB_DIR).expect("could not create database path");
|
std::fs::create_dir_all(&*zed::paths::DB_DIR).expect("could not create database path");
|
||||||
fs::create_dir_all(&*zed::paths::LOGS_DIR).expect("could not create logs path");
|
std::fs::create_dir_all(&*zed::paths::LOGS_DIR).expect("could not create logs path");
|
||||||
|
|
||||||
// Copy setting files from legacy locations. TODO: remove this after a few releases.
|
// Copy setting files from legacy locations. TODO: remove this after a few releases.
|
||||||
thread::spawn(|| {
|
thread::spawn(|| {
|
||||||
if fs::metadata(&*zed::paths::legacy::SETTINGS).is_ok()
|
if std::fs::metadata(&*zed::paths::legacy::SETTINGS).is_ok()
|
||||||
&& fs::metadata(&*zed::paths::SETTINGS).is_err()
|
&& std::fs::metadata(&*zed::paths::SETTINGS).is_err()
|
||||||
{
|
{
|
||||||
fs::copy(&*zed::paths::legacy::SETTINGS, &*zed::paths::SETTINGS).log_err();
|
std::fs::copy(&*zed::paths::legacy::SETTINGS, &*zed::paths::SETTINGS).log_err();
|
||||||
}
|
}
|
||||||
|
|
||||||
if fs::metadata(&*zed::paths::legacy::KEYMAP).is_ok()
|
if std::fs::metadata(&*zed::paths::legacy::KEYMAP).is_ok()
|
||||||
&& fs::metadata(&*zed::paths::KEYMAP).is_err()
|
&& std::fs::metadata(&*zed::paths::KEYMAP).is_err()
|
||||||
{
|
{
|
||||||
fs::copy(&*zed::paths::legacy::KEYMAP, &*zed::paths::KEYMAP).log_err();
|
std::fs::copy(&*zed::paths::legacy::KEYMAP, &*zed::paths::KEYMAP).log_err();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -231,9 +230,10 @@ fn init_logger() {
|
|||||||
const KIB: u64 = 1024;
|
const KIB: u64 = 1024;
|
||||||
const MIB: u64 = 1024 * KIB;
|
const MIB: u64 = 1024 * KIB;
|
||||||
const MAX_LOG_BYTES: u64 = MIB;
|
const MAX_LOG_BYTES: u64 = MIB;
|
||||||
if fs::metadata(&*zed::paths::LOG).map_or(false, |metadata| metadata.len() > MAX_LOG_BYTES)
|
if std::fs::metadata(&*zed::paths::LOG)
|
||||||
|
.map_or(false, |metadata| metadata.len() > MAX_LOG_BYTES)
|
||||||
{
|
{
|
||||||
let _ = fs::rename(&*zed::paths::LOG, &*zed::paths::OLD_LOG);
|
let _ = std::fs::rename(&*zed::paths::LOG, &*zed::paths::OLD_LOG);
|
||||||
}
|
}
|
||||||
|
|
||||||
let log_file = OpenOptions::new()
|
let log_file = OpenOptions::new()
|
||||||
@ -289,7 +289,7 @@ fn init_panic_hook(app_version: String, http: Arc<dyn HttpClient>, background: A
|
|||||||
.body(body.into())?;
|
.body(body.into())?;
|
||||||
let response = http.send(request).await.context("error sending panic")?;
|
let response = http.send(request).await.context("error sending panic")?;
|
||||||
if response.status().is_success() {
|
if response.status().is_success() {
|
||||||
fs::remove_file(child_path)
|
std::fs::remove_file(child_path)
|
||||||
.context("error removing panic after sending it successfully")
|
.context("error removing panic after sending it successfully")
|
||||||
.log_err();
|
.log_err();
|
||||||
} else {
|
} else {
|
||||||
@ -338,7 +338,7 @@ fn init_panic_hook(app_version: String, http: Arc<dyn HttpClient>, background: A
|
|||||||
};
|
};
|
||||||
|
|
||||||
let panic_filename = chrono::Utc::now().format("%Y_%m_%d %H_%M_%S").to_string();
|
let panic_filename = chrono::Utc::now().format("%Y_%m_%d %H_%M_%S").to_string();
|
||||||
fs::write(
|
std::fs::write(
|
||||||
zed::paths::LOGS_DIR.join(format!("zed-{}-{}.panic", app_version, panic_filename)),
|
zed::paths::LOGS_DIR.join(format!("zed-{}-{}.panic", app_version, panic_filename)),
|
||||||
&message,
|
&message,
|
||||||
)
|
)
|
||||||
@ -395,7 +395,7 @@ fn stdout_is_a_pty() -> bool {
|
|||||||
fn collect_path_args() -> Vec<PathBuf> {
|
fn collect_path_args() -> Vec<PathBuf> {
|
||||||
env::args()
|
env::args()
|
||||||
.skip(1)
|
.skip(1)
|
||||||
.filter_map(|arg| match fs::canonicalize(arg) {
|
.filter_map(|arg| match std::fs::canonicalize(arg) {
|
||||||
Ok(path) => Some(path),
|
Ok(path) => Some(path),
|
||||||
Err(error) => {
|
Err(error) => {
|
||||||
log::error!("error parsing path argument: {}", error);
|
log::error!("error parsing path argument: {}", error);
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
mod feedback;
|
mod feedback;
|
||||||
pub mod languages;
|
pub mod languages;
|
||||||
pub mod menus;
|
pub mod menus;
|
||||||
pub mod settings_file;
|
|
||||||
pub mod paths;
|
pub mod paths;
|
||||||
|
pub mod settings_file;
|
||||||
#[cfg(any(test, feature = "test-support"))]
|
#[cfg(any(test, feature = "test-support"))]
|
||||||
pub mod test;
|
pub mod test;
|
||||||
|
|
||||||
@ -14,6 +14,7 @@ use collab_ui::CollabTitlebarItem;
|
|||||||
use collections::VecDeque;
|
use collections::VecDeque;
|
||||||
pub use editor;
|
pub use editor;
|
||||||
use editor::{Editor, MultiBuffer};
|
use editor::{Editor, MultiBuffer};
|
||||||
|
|
||||||
use gpui::{
|
use gpui::{
|
||||||
actions,
|
actions,
|
||||||
geometry::vector::vec2f,
|
geometry::vector::vec2f,
|
||||||
@ -23,7 +24,7 @@ use gpui::{
|
|||||||
};
|
};
|
||||||
use language::Rope;
|
use language::Rope;
|
||||||
pub use lsp;
|
pub use lsp;
|
||||||
pub use project::{self, fs};
|
pub use project;
|
||||||
use project_panel::ProjectPanel;
|
use project_panel::ProjectPanel;
|
||||||
use search::{BufferSearchBar, ProjectSearchBar};
|
use search::{BufferSearchBar, ProjectSearchBar};
|
||||||
use serde::Deserialize;
|
use serde::Deserialize;
|
||||||
|
Loading…
Reference in New Issue
Block a user