Skip to content

Commit 8763d2f

Browse files
committed
Align Cursor search method with the tutorial (search_notes)
The article's AI Code Completion and AI Code Review sections (and the repo's own test-snippets.md) reference search_notes(), but the Cursor project shipped the method as find_notes_by_title_and_body(). Rename it in store.py, cli.py, and tests, and match the body shown in the article (docstring, pattern variable, OR alignment). Suite passes (16), ruff 0.14.1 format/check clean.
1 parent b59572d commit 8763d2f

3 files changed

Lines changed: 9 additions & 6 deletions

File tree

cursor-vs-copilot/cursor/src/notes_manager_cursor_test/cli.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ def main(argv: Sequence[str] | None = None) -> int:
114114
return 0
115115

116116
if args.command == "search":
117-
results = store.find_notes_by_title_and_body(args.query)
117+
results = store.search_notes(args.query)
118118
if not results:
119119
print("No notes found.")
120120
return 0

cursor-vs-copilot/cursor/src/notes_manager_cursor_test/store.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -98,16 +98,19 @@ def reindex(self) -> int:
9898
count += 1
9999
return count
100100

101-
def find_notes_by_title_and_body(self, query: str) -> list[Note]:
102-
"""Return notes whose title or body contains `query` (case-insensitive)."""
101+
def search_notes(self, query: str) -> list[Note]:
102+
"""
103+
Return notes whose title or body contains `query` (case-insensitive).
104+
"""
105+
pattern = f"%{query}%"
103106
rows = self._conn.execute(
104107
"""
105108
SELECT * FROM notes
106109
WHERE title LIKE ? COLLATE NOCASE
107-
OR body LIKE ? COLLATE NOCASE
110+
OR body LIKE ? COLLATE NOCASE
108111
ORDER BY created_at DESC
109112
""",
110-
(f"%{query}%", f"%{query}%"),
113+
(pattern, pattern),
111114
).fetchall()
112115
return [self._row_to_note(row) for row in rows]
113116

cursor-vs-copilot/cursor/tests/test_store.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ def test_search_notes_matches_title_and_body(store):
4747
Note(title="Unrelated", body="Nothing to see here", tags=[])
4848
)
4949

50-
results = store.find_notes_by_title_and_body("trip")
50+
results = store.search_notes("trip")
5151
titles = {note.title for note in results}
5252
assert titles == {"Trip Plan", "Work Notes"}
5353

0 commit comments

Comments
 (0)