From c7eb3e0e9d4b1f5d88f9be8313ad7fb8ad497506 Mon Sep 17 00:00:00 2001 From: Dustin Ross Date: Sun, 5 Nov 2023 20:40:58 -0500 Subject: [PATCH 1/2] Remove use of `string-lines` (#4217) The Elisp function `string-lines` is not available prior to Emacs version 28.1, so its presence breaks compatibility with earlier versions. --- lsp-completion.el | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/lsp-completion.el b/lsp-completion.el index f29fe913b91..ae5f7d40280 100644 --- a/lsp-completion.el +++ b/lsp-completion.el @@ -355,8 +355,13 @@ The MARKERS and PREFIX value will be attached to each candidate." ;; `lsp-completion-start-point' above might be from cached/previous completion and ;; pointing to a very distant point, which results in `prefix' being way too long. ;; So let's consider only the first line. - (prefix (car (string-lines prefix))) - (prefix-len (length prefix)) + (prefix-len (let ((idx 0) + (len (length prefix))) + (while (and (< idx len) + (not (= ?\n (elt prefix idx)))) + (setq idx (1+ idx))) + idx)) + (prefix (substring prefix 0 prefix-len)) (prefix-pos 0) (label (downcase candidate)) (label-len (length label)) From 750773261a3dc554c11f5572e718fd1a048c1de6 Mon Sep 17 00:00:00 2001 From: Dustin Ross Date: Mon, 6 Nov 2023 19:17:59 -0500 Subject: [PATCH 2/2] Use `s-lines` to split lines --- lsp-completion.el | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/lsp-completion.el b/lsp-completion.el index ae5f7d40280..fda4ffc240b 100644 --- a/lsp-completion.el +++ b/lsp-completion.el @@ -355,13 +355,8 @@ The MARKERS and PREFIX value will be attached to each candidate." ;; `lsp-completion-start-point' above might be from cached/previous completion and ;; pointing to a very distant point, which results in `prefix' being way too long. ;; So let's consider only the first line. - (prefix-len (let ((idx 0) - (len (length prefix))) - (while (and (< idx len) - (not (= ?\n (elt prefix idx)))) - (setq idx (1+ idx))) - idx)) - (prefix (substring prefix 0 prefix-len)) + (prefix (car (s-lines prefix))) + (prefix-len (length prefix)) (prefix-pos 0) (label (downcase candidate)) (label-len (length label))