-
Notifications
You must be signed in to change notification settings - Fork 12.3k
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
CodeEditor: Ensure suggestions only apply to the instance of the editor that registered them #69995
Conversation
lastFile:packages/grafana-ui/src/components/Monaco/CodeEditor.internal.story.tsx
lastFile:packages/grafana-ui/src/components/Monaco/suggestions.ts
lastFile:packages/grafana-ui/src/components/Monaco/CodeEditor.internal.story.tsx
lastFile:packages/grafana-ui/src/components/Monaco/suggestions.ts
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.
Edit: No tests for this one then 😢
if (getSuggestions) { | ||
this.completionCancel = registerSuggestions(monaco, language, getSuggestions); | ||
} |
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.
What is the logical difference ebtween doing this onMount instead of beforeMount?
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 guess it will happen slightly later, but by doing it onMount
we get access to the editor instance, whereas before mount we only have access to the global monaco instance
|
||
this.modelId = editor.getModel()?.id; |
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 doesn't require a URI? 😮
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.
nope, i think because the model is associated with this editor (as opposed to getting it from the global monaco namespace)
The backport to
To backport manually, run these commands in your terminal: # Fetch latest updates from GitHub
git fetch
# Create a new branch
git switch --create backport-69995-to-v10.0.x origin/v10.0.x
# Cherry-pick the merged commit of this pull request and resolve the conflicts
git cherry-pick -x 61dbad6905264e41e9464032f065993fb50cf4ea
# When the conflicts are resolved, stage and commit the changes
git add . && git commit --no-edit
# Push it to GitHub
git push --set-upstream origin backport-69995-to-v10.0.x
git switch main
# Remove the local backport branch
git branch -D backport-69995-to-v10.0.x Then, create a pull request where the |
…or that registered them (#69995) * user essentials mob! 🔱 lastFile:packages/grafana-ui/src/components/Monaco/CodeEditor.internal.story.tsx * user essentials mob! 🔱 lastFile:packages/grafana-ui/src/components/Monaco/suggestions.ts * user essentials mob! 🔱 lastFile:packages/grafana-ui/src/components/Monaco/CodeEditor.internal.story.tsx * user essentials mob! 🔱 lastFile:packages/grafana-ui/src/components/Monaco/suggestions.ts * remove duplicate editor from story * remove suggestions from story --------- Co-authored-by: Laura Benz <laura.benz@grafana.com> Co-authored-by: Tobias Skarhed <tobias.skarhed@gmail.com> (cherry picked from commit 61dbad6) # Conflicts: # packages/grafana-ui/src/components/Monaco/CodeEditor.tsx
#70067) CodeEditor: Ensure suggestions only apply to the instance of the editor that registered them (#69995) * user essentials mob! 🔱 lastFile:packages/grafana-ui/src/components/Monaco/CodeEditor.internal.story.tsx * user essentials mob! 🔱 lastFile:packages/grafana-ui/src/components/Monaco/suggestions.ts * user essentials mob! 🔱 lastFile:packages/grafana-ui/src/components/Monaco/CodeEditor.internal.story.tsx * user essentials mob! 🔱 lastFile:packages/grafana-ui/src/components/Monaco/suggestions.ts * remove duplicate editor from story * remove suggestions from story --------- Co-authored-by: Laura Benz <laura.benz@grafana.com> Co-authored-by: Tobias Skarhed <tobias.skarhed@gmail.com> (cherry picked from commit 61dbad6) # Conflicts: # packages/grafana-ui/src/components/Monaco/CodeEditor.tsx
What is this feature?
modelId
when registering suggestionsprovideCompletionItems
can check themodelId
against the registeredmodelId
Why do we need this feature?
Who is this feature for?
CodeEditor
Which issue(s) does this PR fix?:
Fixes #69262
Special notes for your reviewer:
i tried to look for a way to write a test that would prevent regressions to this... but i don't think it's possible in react-testing-library 😬
Please check that: