af2daa7ab7dde3674f4861ef684773410b9cccd4

Author
Christopher Boyd <6323077+cpboyd@users.noreply.github.com>
Committer
GitHub <noreply@github.com>
Date

Message

feat(flutter): use up-to-date zsh completion (#11062)

Diff

 1diff --git a/plugins/flutter/_flutter b/plugins/flutter/_flutter
 2deleted file mode 100644
 3index ab6ce4265d04aba15cf9e6717c6be7201b113f0c..0000000000000000000000000000000000000000
 4--- a/plugins/flutter/_flutter
 5+++ /dev/null
 6@@ -1,37 +0,0 @@
 7-#compdef flutter
 8-#autoload
 9-
10-local -a _1st_arguments
11-_1st_arguments=(
12-  "analyze":"Analyze the project's Dart code."
13-  "assemble":"Assemble and build flutter resources."
14-  "attach":"Attach to a running application."
15-  "build":"Flutter build commands."
16-  "channel":"List or switch flutter channels."
17-  "clean":"Delete the build/ and .dart_tool/ directories."
18-  "config":"Configure Flutter settings."
19-  "create":"Create a new Flutter project."
20-  "devices":"List all connected devices."
21-  "doctor":"Show information about the installed tooling."
22-  "drive":"Runs Flutter Driver tests for the current project."
23-  "emulators":"List, launch and create emulators."
24-  "format":" Format one or more dart files."
25-  "help":"Display help information for flutter."
26-  "install":"Install a Flutter app on an attached device."
27-  "logs":"Show log output for running Flutter apps."
28-  "make-host-app-editable":"Moves host apps from generated directories to non-generated directories so that they can be edited by developers."
29-  "precache":"Populates the Flutter tool's cache of binary artifacts."
30-  "pub":"Commands for managing Flutter packages."
31-  "run":"Run your Flutter app on an attached device."
32-  "screenshot":"Take a screenshot from a connected device."
33-  "test":"Run Flutter unit tests for the current project."
34-  "upgrade":"Upgrade your copy of Flutter."
35-  "version":"List or switch flutter versions."
36-)
37-
38-_arguments -C '*:: :->subcmds'
39-
40-if (( CURRENT == 1 )); then
41-  _describe -t commands "flutter command" _1st_arguments
42-  return
43-fi
44diff --git a/plugins/flutter/flutter.plugin.zsh b/plugins/flutter/flutter.plugin.zsh
45index 80b74f64aff52a914480a43647e831498883e50c..44d196cd4a406e5e842c729f824b47804232c795 100644
46--- a/plugins/flutter/flutter.plugin.zsh
47+++ b/plugins/flutter/flutter.plugin.zsh
48@@ -12,3 +12,18 @@ alias flrd="flutter run --debug"
49 alias flrp="flutter run --profile"
50 alias flrr="flutter run --release"
51 alias flupgrd="flutter upgrade"
52+
53+# COMPLETION FUNCTION
54+if (( ! $+commands[flutter] )); then
55+  return
56+fi
57+
58+# If the completion file doesn't exist yet, we need to autoload it and
59+# bind it to `flutter`. Otherwise, compinit will have already done that.
60+if [[ ! -f "$ZSH_CACHE_DIR/completions/_flutter" ]]; then
61+  typeset -g -A _comps
62+  autoload -Uz _flutter
63+  _comps[flutter]=_flutter
64+fi
65+
66+flutter zsh-completion >| "$ZSH_CACHE_DIR/completions/_flutter" &|