-
Notifications
You must be signed in to change notification settings - Fork 560
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add/inter note link searching #2286
Conversation
957a513
to
ca8d3ae
Compare
2951c4c
to
1646fba
Compare
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Adds an auto-complete provider to use Monaco's built-in functionality for searching notes when linking. This patch presents an alternative approach from creating a custom dialog. Due to the way that the auto-complete always returns results even if none are wanted it may be best to look for a custom dialog.
49cbb08
to
613b533
Compare
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Since the other platforms do that I agree, though I wish everything were text search, or full-text but with title priority. There are a couple things we could explore without changing a substantial amount of code:
long term I guess adding a title-search to the search indexer is probably a sound bet anyway. |
Found this again, just want to leave it here for posterity. There's no API to check if the completions are bound already, and since they are bound to the model, not the editor instance, they can persist, which is why we need to ensure we only add them once. microsoft/monaco-editor#2084 (comment) |
This is ready for testing! I hacked it into submission. I probably owe @dmsnell a few cat pictures after he tells me what crimes I have committed. I added extra parameters to the search function to allow searching titles only and excluding an array of IDs. This gives us:
In the process I found the completion provider needed to access the current note ID, so I had to rewire things a little. I ended up removing the singleton tracker and using a state prop and the editor's I also found that the bracket trigger is not sufficient to get the suggestions to pop up when you would expect, so I added a command that binds to Ctrl+Space and only calls |
Oh I also tested passing in the typed text as a quoted phrase rather than splitting it up, but I like the current behavior (split by word) better personally. |
additionalTextEdits, | ||
kind: note.isPinned | ||
? languages.CompletionItemKind.Snippet | ||
: languages.CompletionItemKind.File, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do we all agree that this is right here? I put it in originally as I was exploring the API but I never had strong feelings about it, or if we should try and do anything better with the icons
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we can do something better with it in a follow-up 🤷
// detail: note.preview, | ||
documentation: note.content, | ||
insertText: `[${note.title}](simplenote://note/${note.noteId})`, | ||
sortText: index.toString(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe that this property is used to sort the results. sorting by index should then reflect the sort order in the notes list, as that's how we proceed through notes in the search.
if we want any kind of alphabetical sort we could use note.title
and if we wanted some relevance search we could perform a quick search distance calculation on the note title against the search query. that would put closer matches at the top
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good!!
3e21828
to
8a2ad51
Compare
This could use some refinement and I'm not sure if the trigger key interaction is going to annoy people (pops up automatically when you type a |
export let searchNotes: ( | ||
args: Partial<SearchState>, | ||
maxResults: number | ||
) => [T.EntityId, T.Note | undefined][] = () => []; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this undefined
jumps off the screen - why would we return results for notes that don't exist?
should we not be filtering out those notes before returning them? what is a caller supposed to do if they get a note id without a note?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@belcherj and I were of consensus that it would never return undefined
, but TypeScript was unhappy, so we added this. Please do fix in a follow-up PR if you know the fix for it :)
This PR adds an auto-complete handler to use the search index for the app to generate a list of inter-note links.
It triggers automatically after typing a
[
, or if you dismiss the popup viaESC
or by typing until there are no matches, you can trigger it with Ctrl + Space.n.b. even if the key combo is used, it will only open if there is an open bracket!Changed this to allow inserting a note link with Ctrl+Space at any time.Notes
Can use the full note list search query syntax. E.g. to search for notes with tagclasses
you type[tag:classes
and then hit the autocomplete triggerWe should do a better job adding the singleton autocompleter. It's easy but hacky here.(Graphic somewhat outdated but gives a general idea)