Skip to content

feat: add member-scoped mcpp run/test editor actions - #2

Merged
wellwei merged 4 commits into
mcpp-community:mainfrom
Ximiaw:feat/editor-title-run-test
Aug 6, 2026
Merged

feat: add member-scoped mcpp run/test editor actions#2
wellwei merged 4 commits into
mcpp-community:mainfrom
Ximiaw:feat/editor-title-run-test

Conversation

@Ximiaw

@Ximiaw Ximiaw commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Add mcpp run and mcpp test actions to the editor title bar.
  • Scope both visibility and execution to the mcpp project/member containing the active editor file. In a workspace with members A/B/C, editing A runs/tests A with A as the task cwd.
  • Hide the actions for files opened outside the current VS Code workspace, non-file editors, and resources without an mcpp project.
  • Reuse the existing project resolver and manifest watcher instead of maintaining a workspace-wide findFiles("**/mcpp.toml") flag.
  • Rename the existing status-bar shortcut to $(tools) mcpp: 快捷菜单 so it is distinct from the module availability status item.
  • Prepare extension version 0.2.5; the release tag must be created from merged main, not from the PR head.

Command semantics

These are project/member-level commands. They invoke fixed mcpp run / mcpp test arguments from the resolved member root. They do not treat the active .cpp file as an independently runnable/testable file; that would require target/test mapping and is a separate feature.

The original editorLangId == cpp condition was insufficient because it exposed generic actions for every C++ file. The current mcpp.inProject context is derived from the active resource and its nearest in-workspace mcpp project instead.

Necessity and compatibility

This is a convenience entry point, not required core functionality: the status-bar quick menu and command palette already expose run/test. Editor-title play/test buttons can still coexist with and visually compete with Code Runner and similar extensions. The member-scoped condition limits incorrect exposure, but it does not eliminate that ecosystem-level title-bar conflict.

Test plan

  • npm test: 95 passed
  • npm run package: generated mcpp-vscode-0.2.5.vsix
  • Verified the packaged VSIX manifest reports version 0.2.5
  • Verified packaged dist/src/commands.js contains $(tools) mcpp: 快捷菜单
  • Regression coverage includes multi-member selection, workspace boundaries, context refresh, and status-bar naming

Release order

  1. Review and merge this PR.
  2. Create annotated tag v0.2.5 from the merged main commit.
  3. Let .github/workflows/release.yml run tests/package and create or update the Release assets.

@Ximiaw

Ximiaw commented Aug 6, 2026

Copy link
Copy Markdown
Contributor Author

作用

在mcpp项目内的编辑器标题栏添加带图标的 run/test 按钮,并通过的 "mcpp.inProject" 上下文让按钮仅在 mcpp 项目中显示。

效果如图

image

@wellwei wellwei changed the title feat: add run/test buttons to editor title bar feat: add member-scoped mcpp run/test editor actions Aug 6, 2026
@wellwei
wellwei merged commit 1a8ae33 into mcpp-community:main Aug 6, 2026
@wellwei

wellwei commented Aug 6, 2026

Copy link
Copy Markdown
Member

维护者结论:这个功能属于便捷入口,不是 mcpp 插件的必需核心能力;现有状态栏快捷菜单和命令面板已经能够执行 run/test。

不能只用 editorLangId == cpp(或 =cpp)决定显示。那会让任意 C++ 文件都出现 mcpp 按钮,既可能对非 mcpp 工程执行错误命令,也会与 Code Runner 等多数在编辑器标题栏提供运行按钮的插件产生明显竞争。

本次合并采用的边界是复用现有项目解析逻辑:以当前编辑资源为起点,解析其所在且属于当前 VS Code workspace 的最近 mcpp 工程/member。多 member 工作区 A/B/C 中,编辑 A 的文件只对 A 执行工程级 mcpp run / mcpp test;打开 workspace 外部文件时不显示按钮,也不回退到其他 member 或工作区根。这里的 run/test 是 member 工程级命令,不是“仅运行/测试当前 cpp 文件”。

因此,这个 PR 在限定为 member-aware 的工程级快捷入口后具备可行性;仍需接受其与其他 Code Runner 类扩展在标题栏上的视觉冲突,这是入口位置本身的生态权衡。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants