Merge pull request #101 from mist-go/bug-patches

Bug patches
This commit is contained in:
2026-06-30 21:04:56 +02:00
committed by GitHub
2 changed files with 17 additions and 11 deletions
+17 -9
View File
@@ -10,6 +10,7 @@ use heck::ToSnakeCase;
use mist_api::transpiler::MistConfig; use mist_api::transpiler::MistConfig;
use mist_parser::MistFmtConfig; use mist_parser::MistFmtConfig;
use mist_parser::error::ParseError; use mist_parser::error::ParseError;
use mist_parser::parse_module;
use mist_parser::rev_mapper::{Mapping, MistMap, RustMap}; use mist_parser::rev_mapper::{Mapping, MistMap, RustMap};
use ropey::Rope; use ropey::Rope;
use serde::Deserialize; use serde::Deserialize;
@@ -1119,13 +1120,10 @@ impl LanguageServer for Backend {
self.documents.lock().await.remove(&mist_path); self.documents.lock().await.remove(&mist_path);
let rust_path = mist_to_rust_path(&mist_path); let rust_path = mist_to_rust_path(&mist_path);
self.mapping.lock().await.remove(&rust_path);
if let Some(rust_uri) = clean_lsp_url(&rust_path) { if let Some(rust_uri) = clean_lsp_url(&rust_path) {
let _ = self.rust_analyzer.lock().await.did_close(rust_uri).await; let _ = self.rust_analyzer.lock().await.did_close(rust_uri).await;
} }
self.publish_diagnostics(uri, Vec::new()).await;
} }
async fn completion( async fn completion(
@@ -2009,20 +2007,30 @@ fn compute_mod_decls(
let mut sorted = files.clone(); let mut sorted = files.clone();
sorted.sort(); sorted.sort();
for file in &sorted { for file in &sorted {
let stem = match file.file_stem().and_then(|s| s.to_str()) {
Some(s) => s,
None => continue,
};
// Skip the root package entry file (e.g. main.mist) // Skip the root package entry file (e.g. main.mist)
if *file == package_path { if *file == package_path {
continue; continue;
} }
// Skip any subdirectory package.mist — it's the directory's own // Skip any subdirectory package.mist — it's the directory's own
// entry file, not a sibling submodule. // entry file, not a sibling submodule.
if stem == "package" { if file.file_name().and_then(|s| s.to_str()) == Some("package.mist") {
continue; continue;
} }
mod_decl.push_str(&format!("pub mod {};\n", stem)); // Use the module declaration from the file if present,
// otherwise fall back to file stem.
let mod_name = documents
.get(file)
.and_then(|rope| {
let source = rope.to_string();
parse_module(&source).ok().flatten().map(|(_, name)| name.0)
})
.or_else(|| {
file.file_stem()
.and_then(|s| s.to_str().map(String::from))
});
if let Some(name) = mod_name {
mod_decl.push_str(&format!("pub mod {};\n", name));
}
} }
if dir == src_root { if dir == src_root {
-2
View File
@@ -10,8 +10,6 @@ use std::process;
use std::time; use std::time;
use std::env;
use mist_parser::error; use mist_parser::error;
use crate::modules; use crate::modules;