feat: add dart-main tag and fix flutter test/group button priority#70
feat: add dart-main tag and fix flutter test/group button priority#70tsinis wants to merge 5 commits intozed-extensions:mainfrom
Conversation
Added a new task for running Dart applications with the label "dart run $ZED_STEM".
This change introduces a fallback pattern for standalone Dart files, ensuring that more specific patterns for Flutter and test files take priority.
|
We require contributors to sign our Contributor License Agreement, and we don't have @tsinis on file. You can sign our CLA at https://zed.dev/cla. Once you've signed, post a comment here that says '@cla-bot check'. |
|
@cla-bot check |
|
The cla-bot has been summoned, and re-checked this pull request! |
|
Hi @kingwill101, yes, I believe it does. |
Added new tasks for running flutter tests with specific line numbers for group and single tests, improving the testing workflow for developers.
Update: Why the simple
|
Hi Team!
This PR introduces
dart runsupport for standalone Dart files and fixes several issues with Flutter test/group play buttons in the gutter.Changes
dart-main— new tag fordart runmain()functions in files withdart:SDK importsflutter-mainso tree-sitter returns it with the same step count — sincedart formatplacesdart:imports beforepackage:imports,dart-mainis always processed first and overwritten by more specific tags in Flutter/test files.ERRORroot fallback variants(ERROR ...)variants fordart-main,flutter-main, andflutter-test-main..all(.circular(4))) parse asERRORroot instead ofprogram— without these fallbacks, those files get no play buttons at all.Arrow-body test fixes
grouppatterns (flutter-test-group,dart-test-group) — whenvoid main() => group(...), bothmainandgroupidentifiers share the same row, sogroupoverwrites the more usefultest-maintag.test-singlepatterns —test()calls insidemain() => group("name", () { test(...) })are on separate rows, so they work correctly.Cleanup
#not-match?predicates onflutter-main(a string matchingpackage:flutter/material.dartcan never also matchflutter_testortest).(program ...)/(ERROR ...)root nodes.Known limitations
dart-mainonly matches files withdart:imports (e.g.dart:io,dart:convert). Pure Dart files importing onlypackage:dependencies won't get a play button. This is unavoidable: patterns matching non-dart:imports have later capture positions than flutter imports, so they'd overwriteflutter-mainin Zed's HashMap. Most real CLI tools usedart:imports, so this is a narrow edge case.QueryMatches, and overwrites all specific tags — making a universaldart-mainimpossible without changes to Zed's runnable resolution logic.A note on testing
This extension currently has no test infrastructure for verifying runnables behavior. The tree-sitter CLI (
tree-sitter query) confirms pattern matching and ordering, but Zed's WASM runtime can behave differently — I observed cases where CLI results were correct, but Zed didn't render the expected play button. Introducing a test harness that validates runnables against Zed's actualSyntaxMapMatchesordering would prevent regressions and remove the guesswork from future changes.Verification
Tested with
tree-sitter queryagainst grammar revision80e23c0:dart:ioimport)dart-mainpackage:flutter/material.dart)flutter-mainmain() { group() })flutter-test-main+flutter-test-groupmain() => group())flutter-test-main+flutter-test-singleper testpackage:test/test.dart)dart-test-fileflutter-main