@@ -275,8 +275,9 @@ public final class SuggestionWidgetController: NSObject {
275275
276276public extension SuggestionWidgetController {
277277 func suggestCode( fileURL: URL ) {
278- widgetViewModel. endIsProcessing ( )
279278 Task {
279+ markAsProcessing ( true )
280+ defer { markAsProcessing ( false ) }
280281 if let suggestion = await dataSource? . suggestionForFile ( at: fileURL) {
281282 suggestionPanelViewModel. content = . suggestion( suggestion)
282283 suggestionPanelViewModel. isPanelDisplayed = true
@@ -285,7 +286,6 @@ public extension SuggestionWidgetController {
285286 }
286287
287288 func discardSuggestion( fileURL: URL ) {
288- widgetViewModel. endIsProcessing ( )
289289 Task {
290290 await updateContentForActiveEditor ( fileURL: fileURL)
291291 }
@@ -302,12 +302,12 @@ public extension SuggestionWidgetController {
302302 func presentError( _ errorDescription: String ) {
303303 suggestionPanelViewModel. content = . error( errorDescription)
304304 suggestionPanelViewModel. isPanelDisplayed = true
305- widgetViewModel. endIsProcessing ( )
306305 }
307306
308307 func presentChatRoom( fileURL: URL ) {
309- widgetViewModel. endIsProcessing ( )
310308 Task {
309+ markAsProcessing ( true )
310+ defer { markAsProcessing ( false ) }
311311 if let chat = await dataSource? . chatForFile ( at: fileURL) {
312312 chatWindowViewModel. chat = chat
313313 chatWindowViewModel. isPanelDisplayed = true
@@ -347,15 +347,15 @@ public extension SuggestionWidgetController {
347347 }
348348
349349 func closeChatRoom( fileURL: URL ) {
350- widgetViewModel. endIsProcessing ( )
351350 Task {
352351 await updateContentForActiveEditor ( fileURL: fileURL)
353352 }
354353 }
355354
356355 func presentPromptToCode( fileURL: URL ) {
357- widgetViewModel. endIsProcessing ( )
358356 Task {
357+ markAsProcessing ( true )
358+ defer { markAsProcessing ( false ) }
359359 if let provider = await dataSource? . promptToCodeForFile ( at: fileURL) {
360360 suggestionPanelViewModel. content = . promptToCode( provider)
361361 suggestionPanelViewModel. isPanelDisplayed = true
@@ -371,7 +371,6 @@ public extension SuggestionWidgetController {
371371 }
372372
373373 func discardPromptToCode( fileURL: URL ) {
374- widgetViewModel. endIsProcessing ( )
375374 Task {
376375 await updateContentForActiveEditor ( fileURL: fileURL)
377376 }
0 commit comments