-
-
Notifications
You must be signed in to change notification settings - Fork 110
Feature/sql query formatting #66
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
Feature/sql query formatting #66
Conversation
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.
Pull request overview
This pull request adds SQL formatting capabilities to the Monaco editor by integrating the sql-formatter library. The implementation creates a reusable hook that registers document and range formatting providers, enabling users to format their SQL code both for entire documents and selected ranges with proper error handling.
Key Changes:
- Added
sql-formatterlibrary as a dependency for SQL formatting functionality - Created
useSqlFormattingProvidershook to encapsulate formatting provider registration logic - Enabled
formatOnPasteoption in the Monaco editor for improved user experience
Reviewed changes
Copilot reviewed 4 out of 5 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
ui/package.json |
Added sql-formatter dependency to enable SQL formatting features |
ui/src/lib/monaco/sql-formatting.ts |
Implemented reusable hook for registering document and range formatting providers with error handling |
ui/src/lib/monaco/index.ts |
Exported the new formatting hook for use in components |
ui/src/components/editor.tsx |
Integrated formatting providers using the new hook and enabled format-on-paste |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| "lucide-react": "^0.533.0", | ||
| "monaco-editor": "^0.52.2", | ||
| "monaco-sql-languages": "^0.15.1", | ||
| "sql-formatter": "15.4.6", |
Copilot
AI
Nov 30, 2025
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.
The sql-formatter version is missing the caret (^) prefix that is used consistently for all other dependencies in this file. This could lead to stricter version locking than intended. Consider using "^15.4.6" to allow minor and patch updates while preventing breaking major version changes.
| "sql-formatter": "15.4.6", | |
| "sql-formatter": "^15.4.6", |
| @@ -0,0 +1 @@ | |||
| export { useSqlFormattingProviders } from "./sql-formatting" No newline at end of file | |||
Copilot
AI
Nov 30, 2025
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.
Missing semicolon at the end of the export statement. The codebase consistently uses semicolons (see ui/src/lib/utils.ts and ui/src/components/editor.tsx), so this should have one as well for consistency.
| export { useSqlFormattingProviders } from "./sql-formatting" | |
| export { useSqlFormattingProviders } from "./sql-formatting"; |
| disposablesRef.current.forEach((d) => d.dispose()); | ||
| disposablesRef.current = []; | ||
| }; | ||
| }, [monaco, languageId, getOptions]); |
Copilot
AI
Nov 30, 2025
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.
Including getOptions in the dependency array will cause the formatting providers to be re-registered whenever a new function reference is passed, even if the function's behavior is identical. Since getOptions is an optional callback function, it's likely to be recreated on every render unless the caller memoizes it. Consider either: (1) removing getOptions from the dependency array with an ESLint disable comment explaining it's intentionally stable, or (2) documenting that callers should use useCallback to memoize getOptions.
|
Thank you. I will handle the AI reviews. |
This pull request introduces SQL formatting capabilities to the Monaco editor by integrating the
sql-formatterlibrary and adding formatting providers. The main changes focus on improving the SQL editing experience by enabling automatic formatting for both entire documents and selected ranges, and refactoring formatting logic into a dedicated hook for better code organization.SQL Formatting Integration:
sql-formatteras a dependency topackage.jsonto enable SQL formatting features.useSqlFormattingProvidershook inui/src/lib/monaco/sql-formatting.tsto register document and range formatting providers for SQL in Monaco, using sensible defaults and error handling.ui/src/lib/monaco/index.tsfor use in other components.Editor Component Enhancements:
useSqlFormattingProvidersinui/src/components/editor.tsx, keeping the component lean and maintainable. [1] [2]