Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix some length usage #27

Merged
merged 6 commits into from
Jan 24, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
ocaml-eglot unreleased
======================

- Use a more efficient way to ensure that a vector is empty ([#27](https://github.com/tarides/ocaml-eglot/pull/27))
- Made the mode-line "lighter" more conventional ([#26](https://github.com/tarides/ocaml-eglot/pull/26))

ocaml-eglot 1.0.0
Expand Down
2 changes: 1 addition & 1 deletion ocaml-eglot-type-enclosing.el
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ If CURRENT is set, the range of the enclosing will be highlighted."
(font-lock-fontify-region (point-min) (point-max))
(buffer-string)))
(display-buffer ocaml-eglot-type-buffer-name))
(when (and current (> (length ocaml-eglot-type-enclosing-types) 0))
(when (and current (not (equal [] ocaml-eglot-type-enclosing-types)))
(let ((current (aref ocaml-eglot-type-enclosing-types
ocaml-eglot-type-enclosing-offset)))
(ocaml-eglot-util--highlight-range current
Expand Down
2 changes: 1 addition & 1 deletion ocaml-eglot-util.el
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@

(defun ocaml-eglot-util--vec-first-or-nil (vec)
"Return the first element of VEC or nil."
(when (> (length vec) 0)
(when (not (equal vec []))
(aref vec 0)))

(defun ocaml-eglot-util--load-uri (uri)
Expand Down
4 changes: 2 additions & 2 deletions ocaml-eglot.el
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ If NEED-CONFIRMATION is set to non-nil, it will prompt a confirmation."

(defun ocaml-eglot--first-hole-aux (holes pos comparison)
"Return the first hole of the list HOLES since a POS using COMPARISON."
(when (or holes (> 0 (length holes)))
(when (or holes (not (equal [] holes)))
(let* ((hd (car holes))
(tl (cdr holes))
(h-start (cl-getf hd :start))
Expand Down Expand Up @@ -446,7 +446,7 @@ It use the ARG to use local values or not."
(result (ocaml-eglot-req--construct hole-start 1 with-local-value))
(range (cl-getf result :position))
(suggestions (append (cl-getf result :result) nil)))
(when (= (length suggestions) 0)
(when (equal suggestions [])
(eglot--error "No constructors for this hole"))
(cl-labels
((insert-construct-choice (subst)
Expand Down
Loading