@@ -29,7 +29,6 @@ export const saveNoteComment = (
2929 ) ;
3030 thread . comments = [ ...thread . comments , newComment ] ;
3131 if ( firstComment ) {
32- updateNoteStatus ( newComment , NoteStatus . TODO , true ) ;
3332 thread . contextValue = uuidv4 ( ) ;
3433 noteMap . set ( thread . contextValue , thread ) ;
3534 }
@@ -45,8 +44,20 @@ export const setNoteStatus = (
4544 author ?: string ,
4645 remoteDb ?: RemoteDb ,
4746) => {
47+ const comment : vscode . Comment | any = thread . comments [ 0 ] ;
48+
49+ // Remove previous status if any
50+ let removed = false ;
51+ Object . values ( NoteStatus ) . forEach ( ( noteStatus ) => {
52+ if ( ! removed && comment . body . toString ( ) . startsWith ( `[${ noteStatus } ] ` ) ) {
53+ comment . body = comment . body . toString ( ) . slice ( noteStatus . length + 3 ) ;
54+ removed = true ;
55+ }
56+ } ) ;
57+
4858 // Prepend new status on first note comment
49- updateNoteStatus ( thread . comments [ 0 ] , status , false ) ;
59+ comment . body = `[${ status } ] ${ comment . body } ` ;
60+ comment . savedBody = comment . body ;
5061
5162 // Add note comment about status change
5263 saveNoteComment (
@@ -59,27 +70,6 @@ export const setNoteStatus = (
5970 ) ;
6071} ;
6172
62- const updateNoteStatus = (
63- comment : vscode . Comment | any ,
64- status : NoteStatus ,
65- firstComment : boolean ,
66- ) => {
67- // Remove previous status if not first comment
68- if ( ! firstComment ) {
69- let removed = false ;
70- Object . values ( NoteStatus ) . forEach ( ( noteStatus ) => {
71- if ( ! removed && comment . body . toString ( ) . startsWith ( `[${ noteStatus } ] ` ) ) {
72- comment . body = comment . body . toString ( ) . slice ( noteStatus . length + 3 ) ;
73- removed = true ;
74- }
75- } ) ;
76- }
77-
78- // Set new status
79- comment . body = `[${ status } ] ${ comment . body } ` ;
80- comment . savedBody = comment . body ;
81- } ;
82-
8373export const mergeThread = ( local : vscode . CommentThread , remote : any ) : boolean => {
8474 // add comments of new thread to current thread if not exist
8575 // TODO: replace with structuredClone()
0 commit comments