@@ -14,7 +14,6 @@ use lasso::{Spur, ThreadedRodeo};
1414use request:: WorkDoneProgressCreate ;
1515use ropey:: Rope ;
1616use smart_default:: SmartDefault ;
17- use tower_lsp_server:: lsp_types:: request:: { ShowDocument , ShowMessageRequest } ;
1817use tower_lsp_server:: { lsp_types:: * , Client } ;
1918use tracing:: { debug, warn} ;
2019use tree_sitter:: QueryCursor ;
@@ -23,7 +22,7 @@ use xmlparser::{Token, Tokenizer};
2322
2423use crate :: model:: { Model , ModelIndex , ModelType } ;
2524use crate :: record:: Record ;
26- use crate :: utils:: { path_contains, ts_range_to_lsp_range, ByteOffset , ByteRange , MinLoc , RangeExt } ;
25+ use crate :: utils:: { path_contains, ts_range_to_lsp_range, uri_from_file_path , ByteOffset , ByteRange , MinLoc , RangeExt } ;
2726use crate :: { errloc, format_loc, loc, ok, ImStr } ;
2827
2928mod record;
@@ -210,9 +209,12 @@ impl Index {
210209 . or_default ( )
211210 . insert ( module_key. into ( ) , module_path. to_str ( ) . expect ( "non-utf8 path" ) . into ( ) ) ;
212211 if let Some ( duplicate) = duplicate {
213- warn ! ( old = %duplicate, new = ?module_path, "duplicate module {module_name}" ) ;
214- if let Some ( client) = client. clone ( ) {
215- outputs. spawn ( Self :: notify_duplicate_base ( client) ) ;
212+ if let ( Some ( client) , "base" ) = ( client. clone ( ) , module_name. as_str ( ) ) {
213+ tokio:: spawn ( Self :: notify_duplicate_base (
214+ client,
215+ duplicate,
216+ module_path. to_path_buf ( ) ,
217+ ) ) ;
216218 }
217219 }
218220 if tsconfig {
@@ -339,16 +341,16 @@ impl Index {
339341 elapsed : t0. elapsed ( ) ,
340342 } ) )
341343 }
342- async fn notify_duplicate_base ( client : Client ) -> anyhow:: Result < Output > {
344+ async fn notify_duplicate_base ( client : Client , old_path : ImStr , new_path : PathBuf ) -> anyhow:: Result < Output > {
343345 let resp = client
344- . send_request :: < ShowMessageRequest > ( ShowMessageRequestParams {
345- typ : MessageType :: WARNING ,
346- message : concat ! (
346+ . show_message_request (
347+ MessageType :: WARNING ,
348+ concat ! (
347349 "Duplicate base module found. The language server's performance may be affected.\n " ,
348350 "Please configure your workspace (or .odoo_lsp) to only include one version of Odoo as described in the wiki." ,
349351 )
350352 . to_string ( ) ,
351- actions : Some ( vec ! [
353+ Some ( vec ! [
352354 MessageActionItem {
353355 title: "Go to odoo-lsp wiki" . to_string( ) ,
354356 properties: Default :: default ( ) ,
@@ -357,20 +359,42 @@ impl Index {
357359 title: "Dismiss" . to_string( ) ,
358360 properties: Default :: default ( ) ,
359361 } ,
362+ MessageActionItem {
363+ title: "Show conflicting modules" . to_string( ) ,
364+ properties: Default :: default ( ) ,
365+ } ,
360366 ] ) ,
361- } )
367+ )
362368 . await ;
363369 match resp {
364370 Ok ( Some ( resp) ) if resp. title == "Go to odoo-lsp wiki" => {
365371 _ = client
366- . send_request :: < ShowDocument > ( ShowDocumentParams {
372+ . show_document ( ShowDocumentParams {
367373 uri : Uri :: from_str ( "https://github.com/Desdaemon/odoo-lsp/wiki#usage" ) . unwrap ( ) ,
368374 external : Some ( true ) ,
369375 take_focus : None ,
370376 selection : None ,
371377 } )
372378 . await ;
373379 }
380+ Ok ( Some ( resp) ) if resp. title == "Show conflicting modules" => {
381+ _ = client
382+ . show_document ( ShowDocumentParams {
383+ uri : uri_from_file_path ( Path :: new ( old_path. as_str ( ) ) ) . unwrap ( ) ,
384+ external : Some ( false ) ,
385+ take_focus : Some ( true ) ,
386+ selection : None ,
387+ } )
388+ . await ;
389+ _ = client
390+ . show_document ( ShowDocumentParams {
391+ uri : uri_from_file_path ( & new_path) . unwrap ( ) ,
392+ external : Some ( false ) ,
393+ take_focus : Some ( false ) ,
394+ selection : None ,
395+ } )
396+ . await ;
397+ }
374398 _ => { }
375399 }
376400
0 commit comments