Fix SQL mode showing each table entry twice#1775
Open
alex-fedotyev wants to merge 1 commit intografana:mainfrom
Open
Fix SQL mode showing each table entry twice#1775alex-fedotyev wants to merge 1 commit intografana:mainfrom
alex-fedotyev wants to merge 1 commit intografana:mainfrom
Conversation
Dispose Monaco completion and formatting providers on editor unmount. Previously, registerSQL() called monaco.languages.registerCompletionItemProvider and registerDocumentFormattingEditProvider without tracking the returned disposables. Since Monaco stacks providers rather than replacing them, each editor remount added another provider returning the same suggestions, causing duplicate table entries. Now registerSQL() returns an SQLRegistration object with a dispose() method, and SqlEditor calls dispose() in onEditorWillUnmount to clean up stale providers. Co-authored-by: Alex Fedotyev <alex-fedotyev@users.noreply.github.com>
|
|
1 similar comment
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Type of Change
Please check the relevant option.
Bug Fix
What is the bug?
In SQL mode, each table entry appears twice (or more) in the autocomplete suggestions.
registerSQL()insqlProvider.tscallsmonaco.languages.registerCompletionItemProvider()andregisterDocumentFormattingEditProvider()every time the SQL editor mounts, but never disposes of the previous registrations. Since Monaco stacks providers rather than replacing them, each editor remount (e.g. switching between Builder and SQL mode, or navigating between panels) adds another provider returning the same suggestions, causing duplicate table entries that multiply with each remount.How to reproduce
FROMclause to trigger table autocomplete — observe suggestionsRelated Issues
Closes HDX-3957
Please check that:
Special notes for your reviewer
This is a minimal, targeted fix. The root cause is that Monaco's
registerCompletionItemProviderandregisterDocumentFormattingEditProviderreturnIDisposableobjects that must be disposed to remove the provider. Without disposal, providers accumulate and each one independently returns the full set of suggestions, leading to duplicates.registerSQL()now returns anSQLRegistrationobject that captures both disposables and exposes adispose()method.SqlEditorstores this in a ref and callsdispose()inonEditorWillUnmount.All 64 existing test suites (592 tests) continue to pass.