@@ -181,43 +181,62 @@ export function activate(context: vscode.ExtensionContext) {
181181 ) ,
182182 ) ;
183183
184- // set note status as vulnerable button
184+ /**
185+ * Handles the common logic for setting a note's status via a command.
186+ *
187+ * @param reply The argument passed by the command (either CommentReply or just the thread).
188+ * @param status The NoteStatus to set (TODO, Vulnerable, Not Vulnerable).
189+ * @param noteMap The object storing all notes in memory.
190+ * @param remoteDb Remote db for collaboration.
191+ */
192+ const handleSetStatusAction = (
193+ reply : vscode . CommentReply | { thread : vscode . CommentThread } ,
194+ status : NoteStatus ,
195+ noteMap : Map < string , vscode . CommentThread > ,
196+ remoteDb ?: RemoteDb
197+ ) => {
198+ const thread = reply . thread ;
199+ // Extract the text of the reply box
200+ const text = 'text' in reply ? reply . text : undefined ;
201+
202+ // Set the status (this function handles adding the status change comment)
203+ setNoteStatus (
204+ thread ,
205+ status , // New status to set
206+ noteMap ,
207+ '' ,
208+ remoteDb ,
209+ text // Reply text
210+ ) ;
211+ } ;
212+
213+ // --- Register the status commands ---
214+
215+ // Set note status as Vulnerable button
185216 context . subscriptions . push (
186217 vscode . commands . registerCommand (
187218 'security-notes.setNoteStatusVulnerable' ,
188- ( commentReply : vscode . CommentReply ) =>
189- setNoteStatus (
190- commentReply . thread ,
191- NoteStatus . Vulnerable ,
192- noteMap ,
193- '' ,
194- remoteDb ,
195- ) ,
196- ) ,
219+ ( reply : vscode . CommentReply | { thread : vscode . CommentThread } ) =>
220+ handleSetStatusAction ( reply , NoteStatus . Vulnerable , noteMap , remoteDb )
221+ )
197222 ) ;
198223
199- // set note status as not vulnerable button
224+ // Set note status as Not Vulnerable button
200225 context . subscriptions . push (
201226 vscode . commands . registerCommand (
202227 'security-notes.setNoteStatusNotVulnerable' ,
203- ( commentReply : vscode . CommentReply ) =>
204- setNoteStatus (
205- commentReply . thread ,
206- NoteStatus . NotVulnerable ,
207- noteMap ,
208- '' ,
209- remoteDb ,
210- ) ,
211- ) ,
228+ ( reply : vscode . CommentReply | { thread : vscode . CommentThread } ) =>
229+ handleSetStatusAction ( reply , NoteStatus . NotVulnerable , noteMap , remoteDb )
230+ )
212231 ) ;
213232
214- // set note status as TODO button
233+ // Set note status as TODO button
215234 context . subscriptions . push (
216235 vscode . commands . registerCommand (
217236 'security-notes.setNoteStatusToDo' ,
218- ( commentReply : vscode . CommentReply ) =>
219- setNoteStatus ( commentReply . thread , NoteStatus . TODO , noteMap , '' , remoteDb ) ,
220- ) ,
237+ ( reply : vscode . CommentReply | { thread : vscode . CommentThread } ) =>
238+ handleSetStatusAction ( reply , NoteStatus . TODO , noteMap , remoteDb )
239+ )
221240 ) ;
222241
223242 // webview for importing tool results
0 commit comments