@@ -51,6 +51,15 @@ Useful if multiple Flutter installations are present."
5151
5252; ; Internal
5353
54+ (defvar-local lsp-dart--project-type-cache nil )
55+
56+ (defun lsp-dart--set-project-type-cache (flutter? )
57+ " Update project type cache checking FLUTTER?."
58+ (if flutter?
59+ (setq lsp-dart--project-type-cache 'flutter )
60+ (setq lsp-dart--project-type-cache 'dart ))
61+ flutter?)
62+
5463(defun lsp-dart--flutter-repo-p ()
5564 " Return non-nil if buffer is the flutter repository."
5665 (if-let (bin-path (locate-dominating-file default-directory lsp-dart-flutter-executable))
@@ -61,13 +70,17 @@ Useful if multiple Flutter installations are present."
6170
6271(defun lsp-dart--flutter-project-p ()
6372 " Return non-nil if buffer is a flutter project."
64- (or (lsp-dart--flutter-repo-p)
65- (-when-let (pubspec-path (-some->> (lsp-dart-get-project-root)
66- (expand-file-name " pubspec.yaml" )))
67- (with-temp-buffer
68- (insert-file-contents pubspec-path)
69- (goto-char (point-min ))
70- (re-search-forward " sdk\s *:\s *flutter" nil t )))))
73+ (if lsp-dart--project-type-cache
74+ (eq lsp-dart--project-type-cache 'flutter )
75+ (let ((flutter-project? (or (-when-let (pubspec-path (-some->> (lsp-dart-get-project-root)
76+ (expand-file-name " pubspec.yaml" )))
77+ (with-temp-buffer
78+ (insert-file-contents pubspec-path)
79+ (goto-char (point-min ))
80+ (re-search-forward " sdk\s *:\s *flutter" nil t )))
81+ (lsp-dart--flutter-repo-p))))
82+ (lsp-dart--set-project-type-cache flutter-project?)
83+ flutter-project?) ))
7184
7285(defun lsp-dart-remove-from-alist (key alist )
7386 " Remove item with KEY from ALIST."
0 commit comments