Commit 4046a15
authored
[issues/162] Add
* Introduce `BookmarkStore` and tests
* Integrate `BookmarksStore` in `extension.ts`
* Bring `nanoid` dependency to avoid relying on `node:crypto` that might not be there for older vscode versions
* Ran `format:fix`
* Avoid repetition for default empty structure (in a functional-leaning friendly way)
* Simplify constructor
* Bookmark-persisting operations are now async instead of silently swallowing the potential errors
* Cleanup comments
* Create and export `createIsoTimestamp()`
* Centralize type definition
* Centralize timestamp generation
* Introduced `BookmarkId` type
* Introduce `findBookmarkIndex()` to decreaser copy-pasta
* Update `import`s
* Majoir test updates; I need to scrutinize them…
* Adding a bookmark now logs the whole object
* Bookmark-handling methods now log the whole bookmark object to produce richer logs
* Ran `format:fix`
* Externalize `createMockMemento()` to align with other test helpers
* BookmarkStore now throws an error when it can successfully initialize
Summary of changes:
- Constructor now throws BOOKMARK_STORE_NOT_AVAILABLE error when globalState is undefined
- Removed defensive null checks in load() and save() - no longer needed
- Updated globalState parameter type from GlobalStateWithSync | undefined to GlobalStateWithSync
This fail-fast approach ensures the extension knows immediately if bookmarks won't work, rather than silently failing later.
* Create cleaner `context` in tests
* Decrease copy-pasta in new tests by better organizing root-level variables
* Decreased copy-pasta in tests to simplify setups
* Bookmark id generation is now collision-safe and has a cap of 10 retries max (with unique error code on failure)
* Update `BookmarkStore` to return `Result`s
This converted the code to stop throwing errors. At the same time, introduced `toBeRangeLinkExtensionErrorErr()` custom matcher that we didn’t yet have.
Also added `BOOKMARK_NOT_FOUND` error code
* Constructor and persistence-related methods now log `syncEnabled` attribute
* Logging must be tested within each method as normal flow
* Tests must freeze the contract instead of using constants
* Updating a bookmark logs the original oneBookmarksStore for cross-workspace bookmark persistence (#184)1 parent 2737dc6 commit 4046a15
File tree
17 files changed
+1394
-48
lines changed- packages/rangelink-vscode-extension
- src
- __tests__
- __mocks__
- helpers
- matchers
- setup
- bookmarks
- __tests__
- errors
- utils
17 files changed
+1394
-48
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
28 | 28 | | |
29 | 29 | | |
30 | 30 | | |
| 31 | + | |
| 32 | + | |
31 | 33 | | |
32 | 34 | | |
33 | 35 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
267 | 267 | | |
268 | 268 | | |
269 | 269 | | |
| 270 | + | |
270 | 271 | | |
271 | 272 | | |
272 | 273 | | |
| |||
Lines changed: 13 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
0 commit comments