@@ -75,79 +75,43 @@ export async function openDialecticUrl(
7575 targetLine = parsed . line . startLine ;
7676 targetColumn = parsed . line . startColumn || 1 ;
7777 }
78- } else if ( needsDisambiguation ( searchResults ) ) {
79- // Multiple matches - check placement memory first
78+ } else {
79+ // Check if we have a stored placement
8080 const linkKey = `link:${ dialecticUrl } ` ;
8181 const placementState = placementMemory ?. get ( linkKey ) ;
8282
8383 if ( placementState ?. isPlaced && placementState . chosenLocation ) {
84- // Use previously placed location
85- const rememberedChoice = placementState . chosenLocation ;
86- // Check if remembered choice is still valid in current results
87- const stillValid = searchResults . find ( r =>
88- r . line === rememberedChoice . line &&
89- r . column === rememberedChoice . column &&
90- r . text === rememberedChoice . text
91- ) ;
84+ // Use stored placement
85+ const storedChoice = placementState . chosenLocation ;
86+ targetLine = storedChoice . line ;
87+ targetColumn = storedChoice . column ;
88+ } else if ( searchResults . length === 1 ) {
89+ // Auto-place single results (pre-disambiguated)
90+ const singleResult = searchResults [ 0 ] ;
91+ targetLine = singleResult . line ;
92+ targetColumn = singleResult . column ;
9293
93- if ( stillValid ) {
94- // Show disambiguation with "same as last time" option
95- const selectedResult = await showSearchDisambiguationWithMemory (
96- searchResults , parsed . regex , document , rememberedChoice
97- ) ;
98-
99- if ( selectedResult ) {
100- targetLine = selectedResult . line ;
101- targetColumn = selectedResult . column ;
102- // Update placement memory with new choice
103- placementMemory ?. set ( linkKey , {
104- isPlaced : true ,
105- chosenLocation : selectedResult ,
106- wasAmbiguous : true
107- } ) ;
108- }
109- } else {
110- // Remembered choice no longer valid, show normal disambiguation
111- const selectedResult = await showSearchDisambiguation ( searchResults , parsed . regex , document ) ;
112- if ( selectedResult ) {
113- targetLine = selectedResult . line ;
114- targetColumn = selectedResult . column ;
115- placementMemory ?. set ( linkKey , {
116- isPlaced : true ,
117- chosenLocation : selectedResult ,
118- wasAmbiguous : true
119- } ) ;
120- }
121- }
94+ // Store the auto-placement
95+ placementMemory ?. set ( linkKey , {
96+ isPlaced : true ,
97+ chosenLocation : singleResult ,
98+ wasAmbiguous : false
99+ } ) ;
122100 } else {
123- // No previous choice, show normal disambiguation
101+ // Multiple results - show disambiguation
124102 const selectedResult = await showSearchDisambiguation ( searchResults , parsed . regex , document ) ;
125103 if ( selectedResult ) {
126104 targetLine = selectedResult . line ;
127105 targetColumn = selectedResult . column ;
106+
107+ // Store the choice
128108 placementMemory ?. set ( linkKey , {
129109 isPlaced : true ,
130110 chosenLocation : selectedResult ,
131111 wasAmbiguous : true
132112 } ) ;
133113 }
134114 }
135- } else {
136- // Single clear result or clear winner after prioritization
137- const bestResult = getBestSearchResult ( searchResults ) ;
138- if ( bestResult ) {
139- targetLine = bestResult . line ;
140- targetColumn = bestResult . column ;
141- outputChannel . appendLine ( `Using best result: line ${ targetLine } , column ${ targetColumn } ` ) ;
142-
143- // Auto-place unambiguous links
144- const linkKey = `link:${ dialecticUrl } ` ;
145- placementMemory ?. set ( linkKey , {
146- isPlaced : true ,
147- chosenLocation : bestResult ,
148- wasAmbiguous : false
149- } ) ;
150- }
151115 }
152116 } catch ( error ) {
153117 outputChannel . appendLine ( `Regex search failed: ${ error } ` ) ;
0 commit comments