mirror of
https://github.com/Myriad-Dreamin/tinymist.git
synced 2025-11-23 12:46:43 +00:00
feat: rename modules by path (#645)
* dev: update new changes * feat: rename modules * dev: skip abs test
This commit is contained in:
parent
df5dafbf75
commit
5ae003efcd
46 changed files with 498 additions and 163 deletions
|
|
@ -314,6 +314,8 @@ pub static REDACT_LOC: Lazy<RedactFields> = Lazy::new(|| {
|
|||
RedactFields::from_iter([
|
||||
"location",
|
||||
"uri",
|
||||
"oldUri",
|
||||
"newUri",
|
||||
"range",
|
||||
"changes",
|
||||
"selectionRange",
|
||||
|
|
@ -332,11 +334,6 @@ impl JsonRepr {
|
|||
Self(s)
|
||||
}
|
||||
|
||||
// pub fn new(v: impl serde::Serialize) -> Self {
|
||||
// let s = serde_json::to_value(v).unwrap();
|
||||
// Self(REDACT_URI.redact(s))
|
||||
// }
|
||||
|
||||
pub fn new_redacted(v: impl serde::Serialize, rm: &RedactFields) -> Self {
|
||||
let s = serde_json::to_value(v).unwrap();
|
||||
Self(rm.redact(s))
|
||||
|
|
@ -387,28 +384,17 @@ impl Redact for RedactFields {
|
|||
|
||||
match k {
|
||||
"changes" => {
|
||||
// object range => v
|
||||
let obj = t.as_object().unwrap();
|
||||
m.insert(
|
||||
k.to_owned(),
|
||||
Value::Object(
|
||||
t.as_object()
|
||||
.unwrap()
|
||||
.iter()
|
||||
.map(|(k, v)| {
|
||||
(
|
||||
Path::new(k)
|
||||
.file_name()
|
||||
.unwrap()
|
||||
.to_str()
|
||||
.unwrap()
|
||||
.to_owned(),
|
||||
v.clone(),
|
||||
)
|
||||
})
|
||||
.collect(),
|
||||
obj.iter().map(|(k, v)| (file_name(k), v.clone())).collect(),
|
||||
),
|
||||
);
|
||||
}
|
||||
"uri" | "oldUri" | "newUri" | "targetUri" => {
|
||||
m.insert(k.to_owned(), file_name(t.as_str().unwrap()).into());
|
||||
}
|
||||
"range"
|
||||
| "selectionRange"
|
||||
| "originSelectionRange"
|
||||
|
|
@ -436,6 +422,11 @@ impl Redact for RedactFields {
|
|||
}
|
||||
}
|
||||
|
||||
fn file_name(k: &str) -> String {
|
||||
let name = Path::new(k).file_name().unwrap();
|
||||
name.to_str().unwrap().to_owned()
|
||||
}
|
||||
|
||||
pub struct HashRepr<T>(pub T);
|
||||
|
||||
// sha256
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue