@@ -30,6 +30,7 @@ import { TextNodeSmartTools } from "@/core/service/dataManageService/textNodeSma
3030 */
3131@service ( "controllerUtils" )
3232export class ControllerUtils {
33+ private currentAutoCompleteWindowId : string | undefined ;
3334 constructor ( private readonly project : Project ) { }
3435
3536 /**
@@ -410,6 +411,9 @@ export class ControllerUtils {
410411 const matchingNodes = searchResults . map ( ( result ) => [ result . item . key , result . item . renderName ] ) ;
411412
412413 // 打开自动补全窗口
414+ if ( this . currentAutoCompleteWindowId ) {
415+ SubWindow . close ( this . currentAutoCompleteWindowId ) ;
416+ }
413417 if ( matchingNodes . length > 0 ) {
414418 const windowId = AutoCompleteWindow . open (
415419 this . project . renderer . transformWorld2View ( node . rectangle ) . leftBottom ,
@@ -418,6 +422,7 @@ export class ControllerUtils {
418422 ele . value = value ;
419423 } ,
420424 ) . id ;
425+ this . currentAutoCompleteWindowId = windowId ;
421426 setWindowId ( windowId ) ;
422427 } else {
423428 const windowId = AutoCompleteWindow . open (
@@ -432,6 +437,7 @@ export class ControllerUtils {
432437 ele . value = value ;
433438 } ,
434439 ) . id ;
440+ this . currentAutoCompleteWindowId = windowId ;
435441 setWindowId ( windowId ) ;
436442 }
437443 // 处理[[格式的补全
@@ -464,6 +470,9 @@ export class ControllerUtils {
464470 ] ) ; // 转换为相对时间格式
465471
466472 // 打开自动补全窗口
473+ if ( this . currentAutoCompleteWindowId ) {
474+ SubWindow . close ( this . currentAutoCompleteWindowId ) ;
475+ }
467476 if ( matchingFiles . length > 0 ) {
468477 const windowId = AutoCompleteWindow . open (
469478 this . project . renderer . transformWorld2View ( node . rectangle ) . leftBottom ,
@@ -473,6 +482,7 @@ export class ControllerUtils {
473482 ele . value = `[[${ value } ` ;
474483 } ,
475484 ) . id ;
485+ this . currentAutoCompleteWindowId = windowId ;
476486 setWindowId ( windowId ) ;
477487 } else {
478488 const windowId = AutoCompleteWindow . open (
@@ -484,6 +494,7 @@ export class ControllerUtils {
484494 ele . value = `[[${ value } ` ;
485495 } ,
486496 ) . id ;
497+ this . currentAutoCompleteWindowId = windowId ;
487498 setWindowId ( windowId ) ;
488499 }
489500 } else {
@@ -510,6 +521,9 @@ export class ControllerUtils {
510521 const matchingSections = searchResults . map ( ( result ) => [ result . item . name , "" ] ) ;
511522
512523 // 打开自动补全窗口
524+ if ( this . currentAutoCompleteWindowId ) {
525+ SubWindow . close ( this . currentAutoCompleteWindowId ) ;
526+ }
513527 if ( matchingSections . length > 0 ) {
514528 const windowId = AutoCompleteWindow . open (
515529 this . project . renderer . transformWorld2View ( node . rectangle ) . leftBottom ,
@@ -519,6 +533,7 @@ export class ControllerUtils {
519533 ele . value = `[[${ fileName } #${ value } ` ;
520534 } ,
521535 ) . id ;
536+ this . currentAutoCompleteWindowId = windowId ;
522537 setWindowId ( windowId ) ;
523538 } else {
524539 const windowId = AutoCompleteWindow . open (
@@ -530,6 +545,7 @@ export class ControllerUtils {
530545 ele . value = `[[${ fileName } #${ value } ` ;
531546 } ,
532547 ) . id ;
548+ this . currentAutoCompleteWindowId = windowId ;
533549 setWindowId ( windowId ) ;
534550 }
535551 }
0 commit comments