@@ -21,7 +21,7 @@ export class NESEngine {
2121 private abortController : AbortController | null = null
2222 private onEditApplied ?: ( lineNumber : number ) => void
2323
24- constructor ( private editor : monaco . editor . IStandaloneCodeEditor , private config : NESConfig ) {
24+ constructor ( private editor : monaco . editor . IStandaloneCodeEditor , _config : NESConfig ) {
2525 this . symptomDetector = new SymptomDetector ( )
2626 this . suggestionQueue = new SuggestionQueue ( )
2727 this . renderer = new NESRenderer ( editor )
@@ -120,7 +120,7 @@ export class NESEngine {
120120 }
121121
122122 /**
123- * 显示第一个建议(只显示 Glyph,不展开预览 )
123+ * 显示第一个建议(直接显示预览 )
124124 */
125125 private showFirstSuggestion ( ) : void {
126126 const prediction = this . suggestionQueue . peek ( )
@@ -130,44 +130,19 @@ export class NESEngine {
130130 const total = this . suggestionQueue . size ( )
131131 const progress = total > 1 ? `${ current } /${ total } ` : undefined
132132
133- // 只显示 Glyph 和 HintBar,不展开预览
133+ // 直接显示预览(优化:不需要两次 Tab)
134134 this . renderer . renderSuggestion ( prediction )
135- this . renderer . showHintBar ( prediction . targetLine , prediction . explanation , false , progress )
136-
137- // 设置预览状态为未展开
138- this . previewShown = false
139- }
140- }
141-
142- /**
143- * 切换到预览模式(Tab 键触发)
144- */
145- public togglePreview ( ) : void {
146- const prediction = this . suggestionQueue . peek ( )
147- if ( ! prediction ) {
148- return
149- }
135+ this . renderer . showPreview ( prediction )
136+ this . renderer . showHintBar ( prediction . targetLine , prediction . explanation , true , progress )
150137
151- if ( ! this . previewShown ) {
152138 // 跳转到建议位置
153139 this . editor . setPosition ( {
154140 lineNumber : prediction . targetLine ,
155141 column : 1
156142 } )
157143 this . editor . revealLineInCenter ( prediction . targetLine )
158144
159- // 展开预览
160- this . renderer . showPreview ( prediction )
161-
162- // 计算进度
163- const current = this . suggestionQueue . getCurrentIndex ( ) + 1
164- const total = this . suggestionQueue . size ( )
165- const progress = total > 1 ? `${ current } /${ total } ` : undefined
166-
167- // 更新 HintBar 提示(显示 "Tab Accept")
168- this . renderer . showHintBar ( prediction . targetLine , prediction . explanation , true , progress )
169-
170- // 更新状态
145+ // 设置预览状态为已展开
171146 this . previewShown = true
172147 }
173148 }
@@ -230,16 +205,28 @@ export class NESEngine {
230205 // 只清除渲染,不移除队列
231206 this . renderer . clear ( )
232207
233- // 如果还有建议,重新显示(只显示 Glyph 和 HintBar )
208+ // 如果还有建议,重新显示(直接显示预览 )
234209 const prediction = this . suggestionQueue . peek ( )
235210 if ( prediction ) {
236211 // 计算进度
237212 const current = this . suggestionQueue . getCurrentIndex ( ) + 1
238213 const total = this . suggestionQueue . size ( )
239214 const progress = total > 1 ? `${ current } /${ total } ` : undefined
240215
216+ // 直接显示预览
241217 this . renderer . renderSuggestion ( prediction )
242- this . renderer . showHintBar ( prediction . targetLine , prediction . explanation , false , progress )
218+ this . renderer . showPreview ( prediction )
219+ this . renderer . showHintBar ( prediction . targetLine , prediction . explanation , true , progress )
220+
221+ // 跳转到建议位置
222+ this . editor . setPosition ( {
223+ lineNumber : prediction . targetLine ,
224+ column : 1
225+ } )
226+ this . editor . revealLineInCenter ( prediction . targetLine )
227+
228+ // 设置预览状态
229+ this . previewShown = true
243230 }
244231 }
245232
0 commit comments