[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/company 6206db868a 18/24: Rewrite company-safe-pixel-su
From: |
ELPA Syncer |
Subject: |
[elpa] externals/company 6206db868a 18/24: Rewrite company-safe-pixel-substring to make more tests pass in batch |
Date: |
Mon, 6 Nov 2023 09:57:38 -0500 (EST) |
branch: externals/company
commit 6206db868a48cfa8e788d3329a1b9fbdff8db077
Author: Dmitry Gutov <dmitry@gutov.dev>
Commit: Dmitry Gutov <dmitry@gutov.dev>
Rewrite company-safe-pixel-substring to make more tests pass in batch
vertical-motion doesn't work well in batch mode, so it exposed some corner
cases. And the result is more readable anyway.
The last test still didn't work in batch; make it interactive-only.
---
company.el | 49 +++++++++++++++++++------------------------------
test/frontends-tests.el | 1 +
2 files changed, 20 insertions(+), 30 deletions(-)
diff --git a/company.el b/company.el
index 19c3c9dd23..2209d950cd 100644
--- a/company.el
+++ b/company.el
@@ -2933,7 +2933,7 @@ from the candidates list.")
(let ((from-chars 0)
(to-chars 0)
spw-from spw-to
- spw-from-prev spw-to-prev
+ spw-to-prev
front back
(orig-buf (window-buffer))
(bis buffer-invisibility-spec)
@@ -2948,20 +2948,13 @@ from the candidates list.")
(vertical-motion (cons (/ from (frame-char-width)) 0))
(setq from-chars (point))
- (while (and (<
- (setq spw-from
- (car
- (window-text-pixel-size nil (point-min)
(point) 55555)))
- from)
+ (setq spw-from
+ (car (window-text-pixel-size nil (point-min) (point) 55555)))
+ (while (and (< spw-from from)
(not (eolp)))
- (when (<= spw-from from)
- (setq from-chars (point)))
- (forward-char 1)
- (setq spw-from-prev spw-from))
-
- (when (and (/= from-chars (point-max)) (> spw-from from))
- (goto-char from-chars)
(forward-char 1)
+ (setq spw-from
+ (car (window-text-pixel-size nil (point-min) (point)
55555)))
(setq from-chars (point)))
(if (= from-chars (point-max))
@@ -2972,33 +2965,29 @@ from the candidates list.")
(setq to-chars (point-max))
(vertical-motion (cons (/ to (frame-char-width)) 0))
(setq to-chars (point))
- (while (and (not (eolp))
- (<
- (setq spw-to
- (car
- (window-text-pixel-size nil (point-min)
(point) 55555)))
- to))
- (when (<= spw-to to)
- (setq to-chars (point)))
+ (setq spw-to
+ (car (window-text-pixel-size nil (point-min) (point)
55555)))
+ (while (and (< spw-to to)
+ (not (eolp)))
+ (setq spw-to-prev spw-to)
(forward-char 1)
- (setq spw-to-prev spw-to
- spw-to nil)))
+ (setq spw-to
+ (car (window-text-pixel-size nil (point-min) (point)
55555)))
+ (when (<= spw-to to)
+ (setq to-chars (point)))))
- (unless spw-from-prev (setq spw-from-prev spw-from))
(unless spw-to-prev (setq spw-to-prev spw-to))
(when (> spw-from from)
(setq front (propertize " " 'display
`(space . (:width (,(- spw-from
from)))))))
- (when (and to (or (not spw-to) (> spw-to to)))
+ (when (and to (/= spw-to to))
(setq back (propertize
" " 'display
`(space . (:width (,(- to
- (or
- spw-to-prev
- (car
(window-text-pixel-size
- nil (point-min)
to-chars 55555)))
- )))))))
+ (if (< spw-to to)
+ spw-to
+ spw-to-prev))))))))
(concat front (buffer-substring from-chars to-chars) back)))
(set-window-buffer nil orig-buf t)))))
diff --git a/test/frontends-tests.el b/test/frontends-tests.el
index 3aeb526969..0ae84d26fd 100644
--- a/test/frontends-tests.el
+++ b/test/frontends-tests.el
@@ -496,6 +496,7 @@
"-*-fzzbar"))))
(ert-deftest company-modify-line-with-prettify ()
+ :tags '(interactive)
(with-temp-buffer
(insert "lambda foo bar")
(setq-local prettify-symbols-alist '(("lambda" . ?λ)))
- [elpa] externals/company a6a27340e3 08/24: company-safe-pixel-substring: Handle characters near eol better, (continued)
- [elpa] externals/company a6a27340e3 08/24: company-safe-pixel-substring: Handle characters near eol better, ELPA Syncer, 2023/11/06
- [elpa] externals/company 8a53285ca0 01/24: Try to handle widths of CJK characters better, ELPA Syncer, 2023/11/06
- [elpa] externals/company 8b516c547c 12/24: Handle 'invisible' and character composition by using a buffer again, ELPA Syncer, 2023/11/06
- [elpa] externals/company 315741353e 05/24: Restore compatibility with Emacs < 29, ELPA Syncer, 2023/11/06
- [elpa] externals/company 9805c7a37d 03/24: Eliminate some repeat calls, ELPA Syncer, 2023/11/06
- [elpa] externals/company 57b6414a3a 14/24: Merge branch 'master' into cjk-string-width, ELPA Syncer, 2023/11/06
- [elpa] externals/company 6c579f7000 13/24: Add new test, for the previous, ELPA Syncer, 2023/11/06
- [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 <=
- [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, 2023/11/06
- [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