zed-industries / zed

Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
https://zed.dev
Other
50.81k stars 3.15k forks source link

dart: code snippet Incorrect filling #15895

Open d1y opened 3 months ago

d1y commented 3 months ago

Check for existing issues

Describe the bug / provide steps to reproduce it

stl | stf filled with incorrect label text instead of code snippets

Flutter Stateless Widget
Flutter Stateful Widget

https://github.com/user-attachments/assets/fe213dac-c7ef-48d5-b64f-7178f7c3c598

Environment

Zed: v0.148.0 (Zed Nightly 990774247ecb61ddf69f0325d28eb3b203fc3699) OS: macOS 15.0.0 Memory: 16 GiB Architecture: aarch64

If applicable, add mockups / screenshots to help explain present your vision of the feature

No response

If applicable, attach your Zed.log file to this issue.

Zed.log


C0routine commented 1 month ago

Zed Snippets Guide read, to create Custom Snippets.

  1. ~/.config/zed/snippets/dart.json Create a file in the path. (or download file to the path)
  2. Copy and paste the code below into your ~/.config/zed/snippets/dart.json

now You can insert StatelessWidget via the "stl", "stless" prefix, StatefulWidget via the "stful", "stf" prefix

P.S - There is an issue with the escape sequence not working if it is at the beginning of the line.

{
  "Flutter StatelessWidget": {
    "prefix": ["stless", "stl"],
    "body": [
      "class $0 extends StatelessWidget {",
      "\tconst $0({super.key});\n",
      "\t@override",
      "\tWidget build(BuildContext context) {",
      "\t\treturn Container();",
      "\t}",
      "}\n"
    ],
    "description": "Insert Flutter StatelessWidget"
  },
  "Flutter StatefulWidget": {
    "prefix": ["stful", "stf"],
    "body": [
      "class $0 extends StatefulWidget {",
      "\tconst $0({super.key});\n",
      "\t@override",
      "\tState<$0> createState() => _$0State();",
      "}\n",
      "class _$0State extends State<$0> {",
      "\t@override",
      "\tWidget build(BuildContext context) {",
      "\t\treturn Container();",
      "\t}",
      "}\n"
    ],
    "description": "Insert Flutter StatelessWidget"
  }
}
silvan-talos commented 1 month ago

I am facing this as well after Signing in. Even after logging out, it still doesn't work.