@@ -12,7 +12,9 @@ export class AIFeedbackProvider implements Disposable {
12
12
constructor ( ) {
13
13
// Listen for document close events to clean up contexts
14
14
this . _disposables . push (
15
- workspace . onDidCloseTextDocument ( document => this . removeChangelogDocument ( document . uri ) ) ,
15
+ workspace . onDidCloseTextDocument ( document => {
16
+ this . removeDocument ( document . uri ) ;
17
+ } ) ,
16
18
) ;
17
19
}
18
20
@@ -21,16 +23,19 @@ export class AIFeedbackProvider implements Disposable {
21
23
this . addChangelogUri ( uri ) ;
22
24
}
23
25
24
- private removeChangelogDocument ( uri : Uri ) : void {
25
- this . deleteChangelogFeedback ( uri . toString ( ) ) ;
26
+ private removeDocument ( uri : Uri ) : void {
27
+ const uriString = uri . toString ( ) ;
28
+ this . deleteChangelogFeedback ( uriString ) ;
26
29
this . removeChangelogUri ( uri ) ;
30
+ this . deleteMarkdownDocument ( uriString ) ;
27
31
}
28
32
29
33
private readonly _disposables : Disposable [ ] = [ ] ;
30
34
dispose ( ) : void {
31
35
this . _disposables . forEach ( d => void d . dispose ( ) ) ;
32
36
this . _uriResponses . clear ( ) ;
33
37
this . _changelogFeedbacks . clear ( ) ;
38
+ this . _markdownDocuments . clear ( ) ;
34
39
this . _changelogUris . clear ( ) ;
35
40
this . _updateFeedbackContextDebounced = undefined ;
36
41
this . _updateChangelogContextDebounced = undefined ;
@@ -70,6 +75,18 @@ export class AIFeedbackProvider implements Disposable {
70
75
this . _changelogFeedbacks . delete ( documentUri ) ;
71
76
}
72
77
78
+ // Storage for AI feedback context associated with any document
79
+ private readonly _markdownDocuments = new Map < string , AIResultContext > ( ) ;
80
+ getMarkdownDocument ( documentUri : string ) : AIResultContext | undefined {
81
+ return this . _markdownDocuments . get ( documentUri ) ;
82
+ }
83
+ setMarkdownDocument ( documentUri : string , context : AIResultContext ) : void {
84
+ this . _markdownDocuments . set ( documentUri , context ) ;
85
+ }
86
+ private deleteMarkdownDocument ( documentUri : string ) : void {
87
+ this . _markdownDocuments . delete ( documentUri ) ;
88
+ }
89
+
73
90
// Storage for AI feedback responses by URI
74
91
private readonly _uriResponses = new UriMap < AIFeedbackEvent [ 'sentiment' ] > ( ) ;
75
92
private _updateFeedbackContextDebounced : Deferrable < ( ) => void > | undefined ;
0 commit comments