[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/pyim 58154b8: * pyim-cstring.el (pyim-cstring-words-at-
From: |
ELPA Syncer |
Subject: |
[elpa] externals/pyim 58154b8: * pyim-cstring.el (pyim-cstring-words-at-point): Fix wrong position. |
Date: |
Wed, 8 Dec 2021 05:57:34 -0500 (EST) |
branch: externals/pyim
commit 58154b8626448699fd8f866b1c1c1c21f58da369
Author: Feng Shu <tumashu@163.com>
Commit: Feng Shu <tumashu@163.com>
* pyim-cstring.el (pyim-cstring-words-at-point): Fix wrong position.
---
pyim-cstring.el | 5 +++--
tests/pyim-tests.el | 26 ++++++++++++++++++++++++++
2 files changed, 29 insertions(+), 2 deletions(-)
diff --git a/pyim-cstring.el b/pyim-cstring.el
index a5a353f..149379d 100644
--- a/pyim-cstring.el
+++ b/pyim-cstring.el
@@ -405,8 +405,8 @@ CRITERIA 字符串一般是通过 imobjs 构建的,它保留了用户原始的
(str-offset
(when (and str-beginning-pos str-end-pos)
(if (= current-pos str-end-pos)
- (1+ (- str-end-pos str-beginning-pos))
- (1+ (- current-pos str-beginning-pos)))))
+ (- str-end-pos str-beginning-pos)
+ (- current-pos str-beginning-pos))))
str-offset-adjusted words-alist results)
;; 当字符串长度太长时, `pyim-cstring-split-to-list'
@@ -421,6 +421,7 @@ CRITERIA 字符串一般是通过 imobjs 构建的,它保留了用户原始的
(setq str (substring str 0 (min 9 str-length)))))
(cond
+ ((or (bobp) (eq (point) (line-beginning-position))) nil)
((and str (not (pyim-string-match-p "\\CC" str)))
(setq words-alist
(pyim-cstring-split-to-list str))
diff --git a/tests/pyim-tests.el b/tests/pyim-tests.el
index a8cdc6c..688c27b 100644
--- a/tests/pyim-tests.el
+++ b/tests/pyim-tests.el
@@ -177,6 +177,32 @@
"Hello -yin-hang-hen-xing- Hi Hello
-yin-hang-hen-heng- Hi "
"Hello -yin-hang-hen-hang- Hi")))))
+(ert-deftest pyim-test-pyim-pyim-cstring-words-at-point ()
+ (let ((pyim-dhashcache-code2word (make-hash-table :test #'equal)))
+ (puthash "tian-an" (list "天安") pyim-dhashcache-code2word)
+ (puthash "an-men" (list "安门") pyim-dhashcache-code2word)
+ (puthash "tian-an-men" (list "天安门") pyim-dhashcache-code2word)
+ (with-temp-buffer
+ (insert "天安门abc\n天安门")
+ ;; <I>天安门abc
+ (goto-char (point-min))
+ (should (equal (pyim-cstring-words-at-point) nil))
+ ;; 天<I>安门abc
+ (forward-char 1)
+ (should (equal (pyim-cstring-words-at-point)
+ '(("天安门" 1 2) ("天安" 1 1))))
+ ;; 天安门abc<I>
+ (forward-char 5)
+ (should (equal (pyim-cstring-words-at-point)
+ '(("abc" 3 0))))
+ ;; <I>天安门
+ (forward-char 1)
+ (should (equal (pyim-cstring-words-at-point) nil))
+ ;; 天安门<I>
+ (goto-char (point-max))
+ (should (equal (pyim-cstring-words-at-point)
+ '(("天安门" 3 0) ("安门" 2 0)))))))
+
(ert-deftest pyim-test-pyim-general ()
(let ((pyim-dcache-backend 'pyim-dregcache))
(with-temp-buffer
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [elpa] externals/pyim 58154b8: * pyim-cstring.el (pyim-cstring-words-at-point): Fix wrong position.,
ELPA Syncer <=