|
62 | 62 | ---@type table<string, string> |
63 | 63 | local _paths = nil |
64 | 64 |
|
65 | | -function M.reset_paths() _paths = nil end |
66 | | - |
67 | 65 | ---Execute user's lookup command and pass it to the job callback |
68 | 66 | ---@param lookup_cmd string |
69 | 67 | ---@param callback fun(t: table<string, string>?) |
@@ -105,22 +103,25 @@ end |
105 | 103 | ---@param callback fun(paths: table<string, string>) |
106 | 104 | ---@return nil |
107 | 105 | function M.get(callback) |
108 | | - if _paths then return callback(_paths) end |
109 | 106 | if config.fvm then |
110 | 107 | local fvm_root = fvm_utils.find_fvm_root() |
111 | 108 | local flutter_bin = fvm_utils.flutter_bin_from_fvm(fvm_root) |
112 | 109 | if fvm_root and flutter_bin then |
113 | | - _paths = { |
| 110 | + -- TODO(kaerum): We currently don't cache fvm based paths |
| 111 | + -- because we'd need a multiple entry based cache |
| 112 | + -- that is somehow better than just traversing up |
| 113 | + -- the directory tree looking for the nearest .fvm |
| 114 | + local paths = { |
114 | 115 | flutter_bin = flutter_bin, |
115 | 116 | flutter_sdk = _flutter_sdk_root(flutter_bin), |
116 | 117 | fvm_dir = fvm_root, |
117 | 118 | } |
118 | | - _paths.dart_sdk = _dart_sdk_root(_paths) |
119 | | - _paths.dart_bin = _flutter_sdk_dart_bin(_paths.flutter_sdk) |
120 | | - return callback(_paths) |
| 119 | + paths.dart_sdk = _dart_sdk_root(paths) |
| 120 | + paths.dart_bin = _flutter_sdk_dart_bin(paths.flutter_sdk) |
| 121 | + return callback(paths) |
121 | 122 | end |
122 | 123 | end |
123 | | - |
| 124 | + if _paths then return callback(_paths) end |
124 | 125 | if config.flutter_path then |
125 | 126 | local flutter_path = fn.resolve(config.flutter_path) |
126 | 127 | _paths = { flutter_bin = flutter_path, flutter_sdk = _flutter_sdk_root(flutter_path) } |
|
0 commit comments