Skip to content

Commit 5a19ec5

Browse files
committed
fix: exact tag matching, menu positioning, CI check, and cleanup
- Fix tag bulk delete/export to use exact tag matching (not substring) - Fix tag context menu position to use click coordinates - Remove dead sort code in RemindersPage (completed tasks already filtered) - Fix CI version bump check to handle package.json and tauri.conf.json independently - Remove unused @codemirror/autocomplete dependency
1 parent 4365c5c commit 5a19ec5

5 files changed

Lines changed: 44 additions & 51 deletions

File tree

.github/workflows/ci.yml

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,17 @@ jobs:
3131
MAIN_TAURI_VERSION=$(git show origin/main:src-tauri/tauri.conf.json | grep '"version"' | head -1 | awk -F: '{ print $2 }' | sed 's/[", ]//g')
3232
CURR_TAURI_VERSION=$(grep '"version"' src-tauri/tauri.conf.json | head -1 | awk -F: '{ print $2 }' | sed 's/[", ]//g')
3333
34-
if [ "$MAIN_VERSION" != "$CURR_VERSION" ] || [ "$MAIN_TAURI_VERSION" != "$CURR_TAURI_VERSION" ]; then
35-
echo "Version bumped. Checking for New Features note..."
34+
if [ "$MAIN_VERSION" != "$CURR_VERSION" ]; then
35+
echo "package.json version bumped. Checking for New Features note..."
3636
if [ ! -f "notes/New Features in v${CURR_VERSION}.md" ]; then
37-
echo "Error: Missing notes/New Features in v${CURR_VERSION}.md"
37+
echo "Error: Missing notes/New Features in v${CURR_VERSION}.md for package.json version"
38+
exit 1
39+
fi
40+
fi
41+
if [ "$MAIN_TAURI_VERSION" != "$CURR_TAURI_VERSION" ]; then
42+
echo "tauri.conf.json version bumped. Checking for New Features note..."
43+
if [ ! -f "notes/New Features in v${CURR_TAURI_VERSION}.md" ]; then
44+
echo "Error: Missing notes/New Features in v${CURR_TAURI_VERSION}.md for tauri.conf.json version"
3845
exit 1
3946
fi
4047
fi

package-lock.json

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

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828
]
2929
},
3030
"dependencies": {
31-
"@codemirror/autocomplete": "^6.20.3",
3231
"@tauri-apps/api": "^2.11.1",
3332
"@tauri-apps/plugin-autostart": "^2.5.1",
3433
"@tauri-apps/plugin-dialog": "^2.7.1",

src/components/NoteSearch.tsx

Lines changed: 22 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ export function NoteSearch() {
2222

2323
const [activeTag, setActiveTag] = useState<string | null>(null)
2424
const [tagActionMenuIndex, setTagActionMenuIndex] = useState(0)
25+
const [tagMenuPos, setTagMenuPos] = useState({ x: 0, y: 0 })
2526

2627
if (!showNoteSearch) return null
2728

@@ -31,6 +32,14 @@ export function NoteSearch() {
3132
return isAuto ? n.content.split('\n')[0].trim() || 'New Note' : fileName
3233
}
3334

35+
const getNoteTags = (n: Note): string[] => {
36+
const matches = n.content.match(/![a-zA-Z0-9_-]+/g)
37+
return matches || []
38+
}
39+
40+
const tagMatch = (tag: string) => (n: Note) =>
41+
getNoteTags(n).some((t) => t.toLowerCase() === tag.toLowerCase())
42+
3443
const filteredNotes = notes.filter(
3544
(n) =>
3645
n.content.toLowerCase().includes(noteSearchQuery.toLowerCase()) ||
@@ -40,10 +49,7 @@ export function NoteSearch() {
4049

4150
const allTags = new Set<string>()
4251
notes.forEach((n) => {
43-
const matches = n.content.match(/![a-zA-Z0-9_-]+/g)
44-
if (matches) {
45-
matches.forEach((m) => allTags.add(m.toLowerCase()))
46-
}
52+
getNoteTags(n).forEach((m) => allTags.add(m.toLowerCase()))
4753
})
4854
const tagArray = Array.from(allTags).sort()
4955

@@ -71,11 +77,11 @@ export function NoteSearch() {
7177
e.preventDefault()
7278
const tag = activeTag
7379
setActiveTag(null)
80+
if (!tag) return
81+
const matchNotes = notes.filter(tagMatch(tag))
7482
if (tagActionMenuIndex === 0) {
7583
const doDelete = async () => {
76-
const notesToDelete = notes.filter((n) =>
77-
n.content.toLowerCase().includes(tag.toLowerCase())
78-
)
84+
const notesToDelete = matchNotes
7985
await window.electronAPI.setDialogOpen(true)
8086
const confirmed = await confirm(
8187
`Delete ${notesToDelete.length} notes containing tag ${tag}?`,
@@ -101,9 +107,7 @@ export function NoteSearch() {
101107
doDelete()
102108
} else if (tagActionMenuIndex === 1) {
103109
const doExport = async () => {
104-
const notesToExport = notes.filter((n) =>
105-
n.content.toLowerCase().includes(tag.toLowerCase())
106-
)
110+
const notesToExport = matchNotes
107111
const combinedContent = notesToExport
108112
.map((n) => {
109113
const title = getNoteTitle(n)
@@ -214,9 +218,9 @@ export function NoteSearch() {
214218
<div
215219
className="tag-action-menu"
216220
style={{
217-
position: 'absolute',
218-
top: 50,
219-
left: 16,
221+
position: 'fixed',
222+
top: tagMenuPos.y,
223+
left: tagMenuPos.x,
220224
zIndex: 1000,
221225
background: 'var(--bg-color)',
222226
border: '1px solid var(--border-color)',
@@ -256,9 +260,8 @@ export function NoteSearch() {
256260
e.stopPropagation()
257261
const tag = activeTag
258262
setActiveTag(null)
259-
const notesToDelete = notes.filter((n) =>
260-
n.content.toLowerCase().includes(tag.toLowerCase())
261-
)
263+
if (!tag) return
264+
const notesToDelete = notes.filter(tagMatch(tag))
262265
await window.electronAPI.setDialogOpen(true)
263266
const confirmed = await confirm(
264267
`Delete ${notesToDelete.length} notes containing tag ${tag}?`,
@@ -305,9 +308,8 @@ export function NoteSearch() {
305308
e.stopPropagation()
306309
const tag = activeTag
307310
setActiveTag(null)
308-
const notesToExport = notes.filter((n) =>
309-
n.content.toLowerCase().includes(tag.toLowerCase())
310-
)
311+
if (!tag) return
312+
const notesToExport = notes.filter(tagMatch(tag))
311313
const combinedContent = notesToExport
312314
.map((n) => {
313315
const title = getNoteTitle(n)
@@ -361,6 +363,7 @@ export function NoteSearch() {
361363
e.stopPropagation()
362364
setActiveTag(tag)
363365
setTagActionMenuIndex(0)
366+
setTagMenuPos({ x: e.clientX, y: e.clientY })
364367
setShowNoteActionMenu(false)
365368
}}
366369
>

src/components/RemindersPage.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,8 @@ export const RemindersPage: React.FC<RemindersPageProps> = ({
5656
}
5757
})
5858

59-
// Sort: Overdue first, then soonest, then no target, then done
59+
// Sort: Overdue first, then soonest, then no target
6060
reminders.sort((a, b) => {
61-
if (a.done !== b.done) return a.done ? 1 : -1
6261
if (a.targetMs && b.targetMs) return a.targetMs - b.targetMs
6362
if (a.targetMs) return -1
6463
if (b.targetMs) return 1

0 commit comments

Comments
 (0)