Skip to content

Commit 630b81e

Browse files
authored
Merge pull request #17 from RefactorSecurity/remove-default-todo-status
Remove default TODO status
2 parents 7f51a3e + e9e704a commit 630b81e

File tree

3 files changed

+18
-28
lines changed

3 files changed

+18
-28
lines changed

package-lock.json

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"displayName": "Security Notes",
44
"description": "Create notes during a security code review. Import your favorite SAST tool results and collaborate with others.",
55
"icon": "resources/security_notes_logo.png",
6-
"version": "1.1.0",
6+
"version": "1.1.1",
77
"publisher": "refactor-security",
88
"private": false,
99
"license": "MIT",
@@ -270,4 +270,4 @@
270270
"rethinkdb": "^2.4.2",
271271
"uuid": "^9.0.0"
272272
}
273-
}
273+
}

src/helpers.ts

Lines changed: 13 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -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-
8373
export 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

Comments
 (0)