-
Couldn't load subscription status.
- Fork 19
👍 generate sub local scope option types #270
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
Conversation
WalkthroughThe changes involve significant updates to the option handling system, enhancing type definitions and refining the scope of various options. New types such as Changes
Assessment against linked issues
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
|
Blocked by #269. |
7b070ad to
75e7696
Compare
|
@coderabbitai review |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #270 +/- ##
=======================================
Coverage 84.60% 84.60%
=======================================
Files 63 63
Lines 3372 3372
Branches 291 291
=======================================
Hits 2853 2853
Misses 517 517
Partials 2 2 ☔ View full report in Codecov by Sentry. |
Actions performedReview triggered.
|
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.
Actionable comments posted: 2
Outside diff range, codebase verification and nitpick comments (2)
option/types.ts (1)
Line range hint
82-97: Reconsider inheritance forBufferLocalOption.The
BufferLocalOptioninterface extendsWindowLocalOption, which might not be appropriate as buffer options should not inherit window-specific behaviors. Consider changing the inheritance to directly extendLocalOptionor another more suitable base interface..scripts/gen-option/parse.ts (1)
Line range hint
121-152: Improved type safety and validation in parseBlock function.The changes in the
parseBlockfunction significantly improve type safety and validation. The function now throws aTypeErrorif thescopeis "local" andlocalscopeis undefined, which enforces the correct usage of scope definitions. This is a critical improvement for maintaining the integrity of option scopes.Consider adding more detailed comments or examples in the documentation to explain the relationship between
scopeandlocalscopefor future maintainability.
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (8)
- .scripts/gen-option/format.ts (3 hunks)
- .scripts/gen-option/parse.ts (7 hunks)
- .scripts/gen-option/types.ts (1 hunks)
- option/_generated.ts (129 hunks)
- option/_utils.ts (1 hunks)
- option/nvim/_generated.ts (7 hunks)
- option/types.ts (3 hunks)
- option/vim/_generated.ts (11 hunks)
Additional comments not posted (30)
.scripts/gen-option/types.ts (2)
28-34: Enhancements approved: New constants and types for option handling.The introduction of
OPTION_LOCAL_SCOPES,OPTION_EXPORT_TYPES, andOPTION_CONSTRUCTORS, along with their corresponding types, enhances the flexibility and expressiveness of the option handling system. Verify that these new types and constants are correctly used and integrated into the codebase.Run the following script to verify the usage of new constants and types:
Also applies to: 38-46, 50-54
16-18: Refactor approved: Simplified type checks using constants.The transformation of
isOptionTypeandisOptionScopefrom functions to constant exports usingisLiteralOneOfsimplifies the code and enhances type safety. Ensure that these constants are correctly used across the codebase.Run the following script to verify the usage of
isOptionTypeandisOptionScope:Also applies to: 24-26
.scripts/gen-option/format.ts (2)
3-6: Enhancements approved: Introduction ofContexttype for better option management.The introduction of the
Contexttype and its usage in theformatfunction improve the maintainability and flexibility of the option formatting process. Verify that theContexttype is correctly used and integrated into the option formatting process.Run the following script to verify the usage of the
Contexttype:Also applies to: 80-94
Verification successful
Verification successful:
Contexttype is correctly used and integrated.The
Contexttype is consistently used across multiple files and functions, such ascmdandeval, to manage options and configurations. This confirms its correct integration into the option formatting process, aligning with the intended improvements in maintainability and flexibility.
- Files where
Contextis used:
helper/expr_string.tshelper/execute.tseval/use_eval.tsbatch/collect.tsbatch/batch.tsScripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify the usage of the `Context` type in the option formatting process. # Test: Search for the usage of the `Context` type in option formatting. Expect: Correct usage and integration. rg --type typescript -A 5 $'Context'Length of output: 70
Script:
#!/bin/bash # Description: Verify the usage of the `Context` type in the option formatting process. # Test: Search for the usage of the `Context` type in option formatting. Expect: Correct usage and integration. rg --type ts -A 5 $'Context'Length of output: 4567
21-30: Refactor approved: Enhanced option processing with new context and logic.The updates to
formatOption,getOptionExportType, andgetOptionConstructorenhance the granularity and flexibility of option processing. Verify that these functions are correctly integrated and do not introduce regressions in option formatting.Run the following script to verify the integration of these functions:
Also applies to: 36-60, 64-71
option/_utils.ts (1)
4-20: Refactor approved: ExpandedOptionImplclass for comprehensive option management.The expansion of the
OptionImplclass to implement multiple interfaces for different types of options, along with the expanded import statement, suggests a more comprehensive design that enhances option management. Verify that theOptionImplclass is correctly integrated and does not introduce regressions in option management.Run the following script to verify the integration of the
OptionImplclass:option/types.ts (4)
Line range hint
111-126: LGTM forWindowLocalOption.The
WindowLocalOptioninterface is well-designed, extendingLocalOptionand including methods specific to window options, such asgetWindowandsetWindow.
132-134: LGTM forGlobalOrBufferLocalOption.The type
GlobalOrBufferLocalOptionis correctly defined, combiningGlobalOptionandBufferLocalOptionto handle options that can be either global or buffer-local.
140-142: LGTM forGlobalOrTabPageLocalOption.The type
GlobalOrTabPageLocalOptionis correctly defined, combiningGlobalOptionandTabPageLocalOptionto handle options that can be either global or tab-page-local.
148-150: LGTM forGlobalOrWindowLocalOption.The type
GlobalOrWindowLocalOptionis correctly defined, combiningGlobalOptionandWindowLocalOptionto handle options that can be either global or window-local.option/vim/_generated.ts (10)
190-190: Refinement ofballoonexproption type.The change from
GlobalOrLocalOptiontoGlobalOrBufferLocalOptionforballoonexpraligns with the PR's goal to restrict the scope of options to more appropriate contexts. This change ensures thatballoonexprcan be set globally or at the buffer level, but not at the window level, which is suitable given its usage context.
420-420: Refinement ofcryptmethodoption type.Updating
cryptmethodfromGlobalOrLocalOptiontoGlobalOrBufferLocalOptionis consistent with the intent to limit the scope where encryption methods are applicable. This change is crucial for security, ensuring that encryption settings can be tailored to specific buffers rather than being universally applied, which could lead to unintended security implications.
900-900: Refinement ofkeyoption type.The change from
LocalOptiontoBufferLocalOptionfor thekeyoption is appropriate. This option pertains to encryption keys, which should logically be restricted to the buffer scope for security reasons, ensuring that keys are not inadvertently shared across different buffers or windows.
1090-1092: Refinement ofosfiletypeoption type.The update from
LocalOptiontoBufferLocalOptionforosfiletypeis a sensible change, reflecting the nature of this option which should be configurable at a buffer level, allowing different file types to be associated with different buffers without affecting global or window settings.
1565-1567: Refinement ofshortnameoption type.Changing
shortnamefromLocalOptiontoBufferLocalOptionis logical, as file naming conventions might need to be different across various buffers, especially when working with files from different systems or environments within the same session.
1665-1667: Refinement oftermwinkeyoption type.The update from
LocalOptiontoWindowLocalOptionfortermwinkeycorrectly reflects its usage, which is specific to window contexts. This change ensures that key bindings can be customized per window, which is particularly useful in a multi-window environment.
1681-1681: Refinement oftermwinscrolloption type.The change from
LocalOptiontoBufferLocalOptionfortermwinscrollaligns with the need to have scroll settings adjustable per buffer, which can be crucial for user preferences in environments with multiple buffers displaying different content.
1711-1713: Refinement oftermwinsizeoption type.Updating
termwinsizefromLocalOptiontoWindowLocalOptionis appropriate, as window size preferences may vary between different windows in the same session, allowing for more granular control over the user interface.
1769-1771: Refinement oftextmodeoption type.The change from
LocalOptiontoBufferLocalOptionfortextmodeis well-justified. Given that text mode (such as line endings) can vary from one buffer to another, especially when editing files originating from different operating systems, this change enhances flexibility and correctness.
2119-2119: Refinement ofwincoloroption type.The update from
LocalOptiontoWindowLocalOptionforwincoloris a crucial improvement, ensuring that window-specific color settings are applied correctly, enhancing the visual distinction and customization capabilities of different windows within the editor.option/_generated.ts (1)
3-4: LGTM!The code changes are approved.
.scripts/gen-option/parse.ts (4)
39-44: Enhanced error handling in parse function.The addition of a structured error object in the
errorsarray is a significant improvement. It allows for more detailed error reporting and debugging. This change aligns with best practices for error handling by capturing and logging detailed error information.
54-60: Refined error handling in parse function.The use of a try-catch block around the
parseBlockfunction call is a good practice. It ensures that parsing errors do not terminate the entire parsing process and that they are handled gracefully.
65-69: Detailed error logging in parse function.The detailed logging of parsing errors, including the specific block and line number, is an excellent addition. It enhances the ability to diagnose issues quickly and accurately.
165-165: Return statement in parseBlock function.The structured return of the
Optionobject with all necessary fields is clear and concise. This ensures that all relevant data is encapsulated within a single return object, enhancing the function's usability and integration with other parts of the system.option/nvim/_generated.ts (6)
17-17: Updated type declaration for channel option.Changing the type from
LocalOption<number>toBufferLocalOption<number>clarifies that thechanneloption is specific to buffer-level settings. This change enhances type safety and aligns with the PR's objectives to improve option handling.
129-131: Updated type declaration for scrollback option.The update from
LocalOption<number>toBufferLocalOption<number>for thescrollbackoption is appropriate, as it specifies that this option is relevant only to buffer contexts. This change is consistent with the PR's goal of refining option scope specificity.
326-326: Updated type declaration for statuscolumn option.The change from
LocalOption<string>toWindowLocalOption<string>for thestatuscolumnoption correctly reflects its applicability to window-level settings. This adjustment improves clarity and ensures that the option's scope is accurately represented.
383-385: Updated type declaration for winbar option.The transition from
GlobalOrLocalOption<string>toGlobalOrWindowLocalOption<string>for thewinbaroption is a significant improvement. It clarifies that the option can be global or specific to windows, enhancing the understanding and management of this option's scope.
396-396: Updated type declaration for winblend option.Updating the
winblendoption fromLocalOption<number>toWindowLocalOption<number>is a precise change that aligns with the PR's objectives. It ensures that the option's scope is limited to windows, which is essential for correct settings management.
419-419: Updated type declaration for winhighlight option.The change from
LocalOption<string>toWindowLocalOption<string>for thewinhighlightoption is crucial for ensuring that the option is correctly categorized as window-specific. This enhances type safety and clarity in the codebase.
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.
LGTM. Can we merge this (if so, plz merge it)? @Milly
Fixes #267
Fixes some #268
getTabPage()orsetTabPage()is not implemented.See #268 (comment)
Summary by CodeRabbit
New Features
Contexttype for better management of option types and constructors.Bug Fixes
Documentation
Refactor