Skip to content

Commit 2dfde34

Browse files
committed
Fix Flutter widget guide lines bug
1 parent a247543 commit 2dfde34

File tree

3 files changed

+20
-4
lines changed

3 files changed

+20
-4
lines changed

lsp-dart-flutter-widget-guide.el

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,9 @@ ANCHOR is the anchor point of the widget guide at LINE."
125125
(let ((char start-char))
126126
(while (<= char end-char)
127127
(if (= char start-char)
128-
(setf (nth char chars) lsp-dart-flutter-widget-guide-bottom-corner)
128+
(if (nth char chars)
129+
(setf (nth char chars) lsp-dart-flutter-widget-guide-bottom-corner)
130+
(setq chars (append chars (list lsp-dart-flutter-widget-guide-bottom-corner))))
129131
(if (nth char chars)
130132
(setf (nth char chars) lsp-dart-flutter-widget-guide-horizontal-line)
131133
(setq chars (append chars (list lsp-dart-flutter-widget-guide-horizontal-line)))))
@@ -156,5 +158,20 @@ ANCHOR is the anchor point of the widget guide at LINE."
156158
(--each-indexed chars (lsp-dart-flutter-widget-guide--add-overlay-to buffer line (+ it-index anchor) it))))
157159
guides-by-line)))))
158160

161+
(define-minor-mode lsp-dart-flutter-widget-guides-mode
162+
"Mode for displaying flutter widget guide lines."
163+
nil nil nil
164+
(cond
165+
(lsp-dart-flutter-widget-guides-mode
166+
(add-hook 'lsp-dart-outline-arrived-hook #'lsp-dart-flutter-widget-guide-check nil t))
167+
(t
168+
(progn
169+
(remove-overlays (point-min) (point-max) 'category 'lsp-dart-flutter-widget-guide)
170+
(remove-hook 'lsp-dart-outline-arrived-hook #'lsp-dart-flutter-widget-guide-check t)))))
171+
172+
(add-hook 'lsp-before-open-hook (lambda ()
173+
(when lsp-dart-flutter-widget-guides
174+
(lsp-dart-flutter-widget-guides-mode 1))))
175+
159176
(provide 'lsp-dart-flutter-widget-guide)
160177
;;; lsp-dart-flutter-widget-guide.el ends here

lsp-dart-outline.el

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
(require 'lsp-dart-protocol)
2525
(require 'lsp-dart-utils)
2626
(require 'lsp-dart-code-lens)
27-
(require 'lsp-dart-flutter-widget-guide)
2827

2928
(defcustom lsp-dart-outline t
3029
"Enable the analysis server outline custom method.
@@ -225,8 +224,7 @@ It updates the outline view if it already exists."
225224
NOTIFICATION is Flutter outline notification data received from server.
226225
It updates the Flutter outline view if it already exists."
227226
(lsp-dart-outline--set-metadata workspace notification "current-flutter-outline")
228-
(when lsp-dart-flutter-widget-guides
229-
(lsp-dart-flutter-widget-guide-check notification))
227+
(run-hook-with-args 'lsp-dart-outline-arrived-hook notification)
230228
(when (get-buffer-window "*Flutter Outline*")
231229
(lsp-dart-outline--show-flutter-outline (find-buffer-visiting (lsp--uri-to-path uri)) t)))
232230

lsp-dart.el

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
(require 'lsp-dart-closing-labels)
3535
(require 'lsp-dart-outline)
3636
(require 'lsp-dart-flutter-fringe)
37+
(require 'lsp-dart-flutter-widget-guide)
3738

3839
(defgroup lsp-dart nil
3940
"LSP support for Dart, using dart analysis server."

0 commit comments

Comments
 (0)