Skip to content
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

CodeMirror 6 editor: Fix searches can't cotain spaces, don't appear immediately after typing @@ #16

Merged

Conversation

personalizedrefrigerator
Copy link
Contributor

Summary

This pull request fixes a few issues with note search in CodeMirror 6. Specifically,

  • Unlike the CodeMirror 5 version, the autocomplete dialog didn't appear immediately after typing @@. In CodeMirror 6, it was necessary to type one more character.
  • Searches couldn't contain spaces.

Testing

  1. Link to another note
  2. Verify that the note suggestion window appears after typing @@ (without the need to type an additional character)
  3. Create a new note with spaces in its title
  4. Link to that note with @@ followed by part of the note's name
  5. Create a note with spaces and a # in its title
  6. Enable "select link text after inserting"
  7. Add a link to a note with @@
  8. Verify that the link text has been selected
Screencast_20240227_080621-1.webm

Note

I plan to create another pull request in the next few minutes that fixes a conflict with the snippets plugin.

@personalizedrefrigerator personalizedrefrigerator changed the title Fix search issues in CodeMirror 6 CodeMirror 6 editor: Fix searches can't cotain spaces, don't appear immediately after typing @@ Feb 27, 2024
@@ -18,14 +18,16 @@ export default function codeMirror6Plugin(pluginContext: PluginContext, CodeMirr
const { EditorSelection } = require('@codemirror/state') as typeof CodeMirrorStateType;

const completeMarkdown = async (completionContext: CompletionContext): Promise<CompletionResult> => {
const prefix = completionContext.matchBefore(/[@][@]\w+/);
// Start completions on @@, match any characters that aren't in "()[]{};>,\n"
const prefix = completionContext.matchBefore(/[@][@][^()\[\]{};:>,\n]*/);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just curious, why do you match @@ as [@][@] and not @{2} or even @@ ?

@roman-r-m
Copy link
Owner

Thanks for the update

@roman-r-m roman-r-m merged commit 97ab5db into roman-r-m:master Mar 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants