[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/company fb21b70d97 11/24: Fix tests and indicated regre
|
From: |
ELPA Syncer |
|
Subject: |
[elpa] externals/company fb21b70d97 11/24: Fix tests and indicated regressions |
|
Date: |
Mon, 6 Nov 2023 09:57:37 -0500 (EST) |
branch: externals/company
commit fb21b70d976785147dc700fab8a9b8639c18c9ab
Author: Dmitry Gutov <dgutov@yandex.ru>
Commit: Dmitry Gutov <dgutov@yandex.ru>
Fix tests and indicated regressions
In particular, the one in test
company-create-lines-with-multiple-width-and-keep-prefix, which also relied
on
the previously concatenative property of company--clean-string. We
semi-broke
that feature in company--common-or-matches for wide characters anyway,
though.
---
company.el | 82 +++++++++++++++++++++++++++----------------------
test/frontends-tests.el | 24 ++++++++-------
2 files changed, 58 insertions(+), 48 deletions(-)
diff --git a/company.el b/company.el
index 8c913cff67..ea46149888 100644
--- a/company.el
+++ b/company.el
@@ -1331,8 +1331,7 @@ can retrieve meta-data for them."
;; It's mory efficient to fix it only when they are displayed.
;; FIXME: Adopt the current text's capitalization instead?
(if (eq (company-call-backend 'ignore-case) 'keep-prefix)
- (let ((prefix (company--clean-string company-prefix)))
- (concat prefix (substring candidate (length prefix))))
+ (concat company-prefix (substring candidate (length company-prefix)))
candidate))
(defun company--should-complete ()
@@ -3176,10 +3175,13 @@ If SHOW-VERSION is non-nil, show the version in the
echo area."
(defun company-fill-propertize (value annotation width selected left right)
(let* ((margin (length left))
- (company-common (and company-common (company--clean-string
company-common)))
(common (company--common-or-matches value))
- (_ (setq value (company-reformat (company--pre-render value))
- annotation (and annotation (company--pre-render annotation
t))))
+ (_ (setq value
+ (company--clean-string
+ (company-reformat (company--pre-render value)))
+ annotation (and annotation
+ (company--clean-string
+ (company--pre-render annotation t)))))
(ann-ralign company-tooltip-align-annotations)
(ann-padding (or company-tooltip-annotation-padding 0))
(ann-truncate (< width
@@ -3276,33 +3278,41 @@ If SHOW-VERSION is non-nil, show the version in the
echo area."
str)))
(defun company--clean-string (str)
- (replace-regexp-in-string
- "\\([^[:graph:] ]\\)\\|\\(\ufeff\\)\\|[[:multibyte:]]+"
- (lambda (match)
- (cond
- ((match-beginning 1)
- ;; FIXME: Better char for 'non-printable'?
- ;; We shouldn't get any of these, but sometimes we might.
- ;; The official "replacement character" is not supported by some fonts.
- ;;"\ufffd"
- "?"
- )
- ((match-beginning 2)
- ;; Zero-width non-breakable space.
- "")
- ((let ((msw (company--string-width match)))
- (when (> msw 1)
- (concat
- (propertize
- (make-string (- msw (length match)) ?\ufeff)
- 'display
- ;; !! Experimental stuff.
- `(space . (:width (,(- (* (default-font-width)
- msw)
- (company--string-pixel-width match))))))
- match))))
- (t match)))
- str))
+ (let* ((add-pixels 0)
+ (add-length 0)
+ (new-str
+ (replace-regexp-in-string
+ "\\([^[:graph:] ]\\)\\|\\(\ufeff\\)\\|[[:multibyte:]]+"
+ (lambda (match)
+ (cond
+ ((match-beginning 1)
+ ;; FIXME: Better char for 'non-printable'?
+ ;; We shouldn't get any of these, but sometimes we might.
+ ;; The official "replacement character" is not supported by
some fonts.
+ ;;"\ufffd"
+ "?"
+ )
+ ((match-beginning 2)
+ ;; Zero-width non-breakable space.
+ "")
+ (t
+ ;; FIXME: Maybe move that counting later to a non-replacement
loop.
+ (let ((msw (company--string-width match)))
+ (cl-incf add-pixels
+ (- (* (default-font-width)
+ msw)
+ (company--string-pixel-width match)))
+ (cl-incf add-length (- msw (length match)))
+ match
+ ))
+ ))
+ str)))
+ (if (= 0 add-length)
+ new-str
+ (concat new-str
+ (propertize
+ (make-string add-length ?\ufeff)
+ 'display `(space . (:width (,add-pixels))))))))
;;; replace
@@ -3503,18 +3513,16 @@ but adjust the expected values appropriately."
(annotation (company-call-backend 'annotation value))
(left (or (pop left-margins)
(company-space-string left-margin-size))))
- (setq value (company--clean-string value))
(when annotation
- (setq annotation (company--clean-string annotation))
(when company-tooltip-align-annotations
;; `lisp-completion-at-point' adds a space.
(setq annotation (string-trim-left annotation))))
(push (list value annotation left) items)
- (setq width (max (+ (length value)
+ (setq width (max (+ (company--string-width value)
(if annotation
- (+ (length annotation)
+ (+ (company--string-width annotation)
company-tooltip-annotation-padding)
- (length annotation)))
+ 0))
width))))
(setq width (min window-width
diff --git a/test/frontends-tests.el b/test/frontends-tests.el
index 3b36e232f3..ef877e5deb 100644
--- a/test/frontends-tests.el
+++ b/test/frontends-tests.el
@@ -285,8 +285,8 @@
"avatar"))
(company-candidates-length 2)
(company-backend 'ignore))
- (should (equal '(" avalis?e "
- " avatar ")
+ (should (equal '(" avalis?e "
+ " avatar ")
(cdr (company--create-lines 0 999))))))
(ert-deftest company-create-lines-handles-multiple-width ()
@@ -295,8 +295,8 @@
(company-candidates '("蛙蛙蛙蛙" "蛙abc"))
(company-candidates-length 2)
(company-backend 'ignore))
- (should (equal '(" 蛙蛙蛙蛙 "
- " 蛙abc ")
+ (should (equal '(" 蛙蛙蛙蛙 "
+ " 蛙abc ")
(cdr (company--create-lines 0 999))))))
(ert-deftest company-create-lines-handles-multiple-width-in-annotation ()
@@ -307,8 +307,8 @@
(company-backend (lambda (c &optional a &rest _)
(when (eq c 'annotation)
(assoc-default a alist)))))
- (should (equal '(" a ︸ "
- " b ︸︸ ")
+ (should (equal '(" a ︸ "
+ " b ︸︸ ")
(cdr (company--create-lines 0 999))))))
(ert-deftest company-create-lines-with-multiple-width-and-keep-prefix ()
@@ -321,8 +321,8 @@
(company-backend (lambda (c &rest _)
(pcase c
(`ignore-case 'keep-prefix)))))
- (should (equal '(" MIRAI発売1カ月 "
- " MIRAI発売2カ月 ")
+ (should (equal '(" MIRAI発売1カ月 "
+ " MIRAI発売2カ月 ")
(cdr (company--create-lines 0 999))))))
(ert-deftest company-create-lines-with-format-function ()
@@ -476,14 +476,16 @@
(ert-deftest company-modify-line ()
(let ((str "-*-foobar"))
(should (equal-including-properties
- (company-modify-line str "zz" 4)
+ (company-modify-line str "zz" (* 4 (frame-char-width)))
"-*-fzzbar"))
(should (equal-including-properties
(company-modify-line str "xx" 0)
"xx-foobar"))
(should (equal-including-properties
- (company-modify-line str "zz" 10)
- "-*-foobar zz"))))
+ (company-modify-line str "zz" (* 10 (frame-char-width)))
+ (concat "-*-foobar"
+ (propertize " " 'display `(space :width
(,(frame-char-width))))
+ "zz")))))
(ert-deftest company-modify-line-with-invisible-prop ()
(let ((str (copy-sequence "-*-foobar"))
- [elpa] externals/company ec51f51b22 04/24: Define company-safe-pixel-substring to do more accurate popup positioning, (continued)
- [elpa] externals/company ec51f51b22 04/24: Define company-safe-pixel-substring to do more accurate popup positioning, ELPA Syncer, 2023/11/06
- [elpa] externals/company d19d7a7ae7 23/24: Fix CI in Emacs 29, ELPA Syncer, 2023/11/06
- [elpa] externals/company 705af6470b 17/24: Fix an edge case, ELPA Syncer, 2023/11/06
- [elpa] externals/company 6206db868a 18/24: Rewrite company-safe-pixel-substring to make more tests pass in batch, ELPA Syncer, 2023/11/06
- [elpa] externals/company 44dbc23679 07/24: Fix edge case, ELPA Syncer, 2023/11/06
- [elpa] externals/company 5173cc9693 21/24: Fix CI in Emacs 28-, ELPA Syncer, 2023/11/06
- [elpa] externals/company a1ef2a06a0 20/24: Update NEWS, ELPA Syncer, 2023/11/06
- [elpa] externals/company 7a4bc77e1c 16/24: company-pseudo-tooltip-show: Slight performance improvement, ELPA Syncer, 2023/11/06
- [elpa] externals/company 6ff9f054cb 22/24: More fixing of tests, ELPA Syncer, 2023/11/06
- [elpa] externals/company f6b7bc5c35 10/24: Add handling of buffer-invisibility-spec to company-safe-pixel-substring, ELPA Syncer, 2023/11/06
- [elpa] externals/company fb21b70d97 11/24: Fix tests and indicated regressions,
ELPA Syncer <=
- [elpa] externals/company 1276d0ec1c 15/24: Replace default-font-width with frame-char-width inside company-safe-pixel-substring, ELPA Syncer, 2023/11/06
- [elpa] externals/company 87351c2c59 02/24: Use vertical-motion instead of move-to-column, ELPA Syncer, 2023/11/06
- [elpa] externals/company 4301ea14c5 24/24: Merge pull request #1394 from company-mode/cjk-string-width, ELPA Syncer, 2023/11/06
- [elpa] externals/company ff300894a3 19/24: Add a comment, ELPA Syncer, 2023/11/06