Skip to content

Commit ad8f579

Browse files
committed
Manage region highlighting for type-expr (in the future)
1 parent d697660 commit ad8f579

File tree

1 file changed

+16
-14
lines changed

1 file changed

+16
-14
lines changed

ocaml-eglot-type-enclosing.el

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@
6969
(type (cl-getf result :type)))
7070
(setq ocaml-eglot-type-enclosing-current-type type)
7171
(setq ocaml-eglot-type-enclosing-verbosity nil)
72-
(ocaml-eglot-type-enclosing--display type)))
72+
(ocaml-eglot-type-enclosing--display type t)))
7373

7474
(defun ocaml-eglot-type-enclosing-increase-verbosity ()
7575
"Increase the verbosity of the current request."
@@ -115,18 +115,20 @@
115115
(read-only-mode 1)
116116
(setq default-directory curr-dir))))
117117

118-
(defun ocaml-eglot-type-enclosing--display (type-expr)
119-
"Display the type-enclosing for TYPE-EXPR in a dedicated buffer."
120-
(let ((current-enclosing (aref ocaml-eglot-type-enclosing-types
121-
ocaml-eglot-type-enclosing-offset)))
122-
(ocaml-eglot-type-enclosing--type-buffer type-expr)
123-
(if (ocaml-eglot-util--text-less-than type-expr 8)
124-
(message "%s" (with-current-buffer ocaml-eglot-type-buffer-name
125-
(font-lock-fontify-region (point-min) (point-max))
126-
(buffer-string)))
127-
(display-buffer ocaml-eglot-type-buffer-name))
128-
(ocaml-eglot-util--highlight-range current-enclosing
129-
'ocaml-eglot-highlight-region-face)))
118+
(defun ocaml-eglot-type-enclosing--display (type-expr &optional current-enclosing)
119+
"Display the type-enclosing for TYPE-EXPR in a dedicated buffer.
120+
If CURRENT-ENCLOSING is set, the range of the enclosing will be highlighted."
121+
(ocaml-eglot-type-enclosing--type-buffer type-expr)
122+
(if (ocaml-eglot-util--text-less-than type-expr 8)
123+
(message "%s" (with-current-buffer ocaml-eglot-type-buffer-name
124+
(font-lock-fontify-region (point-min) (point-max))
125+
(buffer-string)))
126+
(display-buffer ocaml-eglot-type-buffer-name))
127+
(when current-enclosing
128+
(let ((current-enclosing (aref ocaml-eglot-type-enclosing-types
129+
ocaml-eglot-type-enclosing-offset)))
130+
(ocaml-eglot-util--highlight-range current-enclosing
131+
'ocaml-eglot-highlight-region-face))))
130132

131133
(defun ocaml-eglot-type-enclosing--reset ()
132134
"Reset local variables defined by the enclosing query."
@@ -147,7 +149,7 @@
147149
(setq ocaml-eglot-type-enclosing-offset index)
148150
(setq ocaml-eglot-type-enclosing-types enclosings)
149151
(setq ocaml-eglot-type-enclosing-current-type type)
150-
(ocaml-eglot-type-enclosing--display type)
152+
(ocaml-eglot-type-enclosing--display type t)
151153
(set-transient-map ocaml-eglot-type-enclosing-map t
152154
'ocaml-eglot-type-enclosing--reset)))
153155

0 commit comments

Comments
 (0)