feat: Add menuconfig abstraction framework with priority-based fallback#34
feat: Add menuconfig abstraction framework with priority-based fallback#34
Conversation
…figuration option Co-authored-by: BernardXiong <1241087+BernardXiong@users.noreply.github.com>
Co-authored-by: BernardXiong <1241087+BernardXiong@users.noreply.github.com>
…ror handling Co-authored-by: BernardXiong <1241087+BernardXiong@users.noreply.github.com>
There was a problem hiding this comment.
Pull Request Overview
This PR implements support for the vscode-kconfig-visual-editor extension as an alternative method for menuconfig operations, with a configurable fallback hierarchy. The implementation adds a new configuration option to force terminal-based menuconfig and centralizes the extension detection logic into reusable utility functions.
Key Changes:
- Added a new
smart.useTerminalMenuconfigconfiguration option to allow users to force terminal-based menuconfig - Created centralized utility functions (
getMenuconfigMethod()) to detect and select the appropriate menuconfig method based on installed extensions - Updated menuconfig invocations in both tree view and BSP context menu to use the new prioritized detection system
Reviewed Changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
package.json |
Added smart.useTerminalMenuconfig boolean configuration option with bilingual descriptions |
src/smart.ts |
Added utility functions and constants for menuconfig method detection with priority ordering (rt-thread-kconfig → vscode-kconfig-visual-editor → terminal fallback) |
src/dock.ts |
Updated tree view menuconfig command to use the new getMenuconfigMethod() utility |
src/project/cmd.ts |
Enhanced BSP context menu menuconfig with special handling for each extension type and error recovery fallback |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
src/project/cmd.ts
Outdated
There was a problem hiding this comment.
The error message 'Failed to open Kconfig file' is misleading because the rejection could come from vscode.window.showTextDocument() rather than opening the document. Consider a more accurate message like 'Failed to open or display Kconfig file'.
src/project/cmd.ts
Outdated
There was a problem hiding this comment.
The 'else' block at lines 64-68 is unreachable because the two preceding if conditions (lines 36 and 43) already cover all possible values of menuconfigMethod.command from MENUCONFIG_COMMANDS. This dead code should be removed or the logic should be restructured if additional extension commands are expected in the future.
| else { | |
| // Generic extension command | |
| executeCommand('cd ' + arg.fn); | |
| vscode.commands.executeCommand(menuconfigMethod.command!); | |
| } |
…ation Co-authored-by: BernardXiong <1241087+BernardXiong@users.noreply.github.com>
|
@flyingcys 还麻烦帮忙review,谢谢。 |
Co-authored-by: BernardXiong <1241087+BernardXiong@users.noreply.github.com>
| */ | ||
| export const MENUCONFIG_COMMANDS = { | ||
| RT_THREAD_KCONFIG: 'rt-thread-kconfig.menuconfig.windows', | ||
| KCONFIG_VISUAL_EDITOR: 'kconfig-visual-editor.open' |
|
@copilot vscode-kconfig-visual-editor 还没完全ready,可以先对 |
- Comment out vscode-kconfig-visual-editor detection and handling - Keep the abstraction framework with TODO comments - Fix error message to be more accurate (open or display) - Remove unreachable else block as it's no longer needed Co-authored-by: BernardXiong <1241087+BernardXiong@users.noreply.github.com>
Done in commit a081765. The vscode-kconfig-visual-editor support has been commented out while preserving the abstraction framework. When the extension is ready, the code can be easily uncommented. Changes made:
|
Adds abstraction framework for menuconfig method selection with configurable priority ordering between graphical and terminal interfaces. Support for
vscode-kconfig-visual-editoris temporarily commented out pending extension readiness.Changes
Configuration
smart.useTerminalMenuconfigsetting to force terminal-only mode regardless of installed extensionsCore Logic (
src/smart.ts)getMenuconfigMethod()implements priority-based detection framework: user preference → rt-thread-kconfig → (vscode-kconfig-visual-editor - commented out) → terminalMENUCONFIG_COMMANDSconstants for extension command stringsMenuconfigMethodinterface for type-safe method selectionIntegration
src/dock.ts) to use centralized detectionsrc/project/cmd.ts) with extension-specific handling:rt-thread-kconfig: Changes to BSP directory and executes commandExample Usage
Current Priority Order
smart.useTerminalMenuconfig→ terminalrt-thread.rt-thread-kconfig→ rt-thread-kconfigvscode-kconfig-visual-editor(commented out, ready for future enablement)scons --menuconfigStatus
The abstraction framework is complete and ready for use. Support for
vscode-kconfig-visual-editoris implemented but commented out pending the extension's readiness. The code can be easily uncommented when the extension is ready to use.Original prompt
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.