Skip to content

Commit

Permalink
fix: do not clobber record names
Browse files Browse the repository at this point in the history
  • Loading branch information
Desdaemon committed May 23, 2024
1 parent 3272e43 commit 785c388
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 9 deletions.
18 changes: 10 additions & 8 deletions src/index.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use dashmap::DashMap;
use globwalk::FileType;
use ignore::gitignore::Gitignore;
use ignore::Match;
use lasso::{Key, Spur, ThreadedRodeo};
use lasso::{Spur, ThreadedRodeo};
use miette::{diagnostic, IntoDiagnostic};
use ropey::Rope;
use smart_default::SmartDefault;
Expand Down Expand Up @@ -100,7 +100,7 @@ impl Interner {
pub struct Index {
/// root -> module key -> module's relpath to root
#[default(_code = "DashMap::with_shard_amount(4)")]
pub roots: DashMap<PathBuf, SymbolMap<Module, ImStr>>,
pub roots: DashMap<PathBuf, HashMap<Symbol<Module>, ImStr>>,
pub records: record::RecordIndex,
pub templates: template::TemplateIndex,
pub models: ModelIndex,
Expand Down Expand Up @@ -212,11 +212,13 @@ impl Index {
module_dir,
root
);
if !self.roots.entry(root.into()).or_default().insert_checked(
module_key.into_usize() as _,
module_path.to_str().expect("non-utf8 path").into(),
) {
warn!("duplicate module {module_name} path={module_path:?}");
if let Some(duplicate) = self
.roots
.entry(root.into())
.or_default()
.insert(module_key.into(), module_path.to_str().expect("non-utf8 path").into())
{
warn!(old = %duplicate, new = ?module_path, "duplicate module {module_name}");
if let (Some((client, _)), "base") = (&progress, module_name.as_str()) {
let resp = client
.send_request::<ShowMessageRequest>(ShowMessageRequestParams {
Expand Down Expand Up @@ -366,7 +368,7 @@ impl Index {
for component in path.components() {
if let Component::Normal(norm) = component {
if let Some(module) = interner().get(&norm.to_string_lossy()) {
if entry.value().contains_key(module.into_usize() as _) {
if entry.value().contains_key(&module.into()) {
return Some(module.into());
}
}
Expand Down
3 changes: 3 additions & 0 deletions src/index/record.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ pub type RecordPrefixTrie = qp_trie::Trie<ImStr, HashSet<RecordId>>;

impl RecordIndex {
pub async fn insert(&self, qualified_id: RecordId, record: Record, prefix: Option<&mut RecordPrefixTrie>) {
if self.inner.contains_key(&qualified_id) {
return;
}
if let Some(model) = &record.model {
self.by_model.entry(*model).or_default().insert(qualified_id);
}
Expand Down
4 changes: 3 additions & 1 deletion testing/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@
odoocmd = [lsp_devtools, "agent", "--", f"{__dirname}/../target/debug/odoo-lsp"]
else:
odoocmd = [f"{__dirname}/../target/debug/odoo-lsp"]
ODOO_ENV = {"RUST_LOG": "info,odoo_lsp=trace", "ODOO_LSP_LOG": "1"}
ODOO_ENV = dict(os.environ)
ODOO_ENV.setdefault('RUST_LOG', 'info,odoo_lsp=trace')
ODOO_ENV.setdefault('ODOO_LSP_LOG', '1')


@pytest.fixture
Expand Down

0 comments on commit 785c388

Please sign in to comment.