@@ -12,7 +12,9 @@ export class AIFeedbackProvider implements Disposable {
1212 constructor ( ) {
1313 // Listen for document close events to clean up contexts
1414 this . _disposables . push (
15- workspace . onDidCloseTextDocument ( document => this . removeChangelogDocument ( document . uri ) ) ,
15+ workspace . onDidCloseTextDocument ( document => {
16+ this . removeDocument ( document . uri ) ;
17+ } ) ,
1618 ) ;
1719 }
1820
@@ -21,16 +23,19 @@ export class AIFeedbackProvider implements Disposable {
2123 this . addChangelogUri ( uri ) ;
2224 }
2325
24- private removeChangelogDocument ( uri : Uri ) : void {
25- this . deleteChangelogDocument ( uri . toString ( ) ) ;
26+ private removeDocument ( uri : Uri ) : void {
27+ const uriString = uri . toString ( ) ;
28+ this . deleteChangelogDocument ( uriString ) ;
2629 this . removeChangelogUri ( uri ) ;
30+ this . deleteMarkdownDocument ( uriString ) ;
2731 }
2832
2933 private readonly _disposables : Disposable [ ] = [ ] ;
3034 dispose ( ) : void {
3135 this . _disposables . forEach ( d => void d . dispose ( ) ) ;
3236 this . _uriResponses . clear ( ) ;
3337 this . _changelogDocuments . clear ( ) ;
38+ this . _markdownDocuments . clear ( ) ;
3439 this . _changelogUris . clear ( ) ;
3540 this . _updateFeedbackContextDebounced = undefined ;
3641 this . _updateChangelogContextDebounced = undefined ;
@@ -70,6 +75,18 @@ export class AIFeedbackProvider implements Disposable {
7075 this . _changelogDocuments . delete ( documentUri ) ;
7176 }
7277
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+
7390 // Storage for AI feedback responses by URI
7491 private readonly _uriResponses = new UriMap < AIFeedbackEvent [ 'sentiment' ] > ( ) ;
7592 private _updateFeedbackContextDebounced : Deferrable < ( ) => void > | undefined ;
0 commit comments