Skip to content

Commit

Permalink
Fix zero-width characters and control characters attribute issue. (#1741
Browse files Browse the repository at this point in the history
)

* Remove unnecessary multiple values return.

* Add Unicode variation selectors to zero-width characters for now.

* Fix the issue of special character attribute.

Previously, if the cursor is at different line than the special
character, Lem will throw out an error.
  • Loading branch information
funk443 authored Jan 9, 2025
1 parent b59ec3b commit f51036d
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/common/character/string-width-utils.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
table))

(defun control-char (char)
(values (gethash char *char-replacement*)))
(gethash char *char-replacement*))

(defun wide-char-p (char)
(declare (character char))
Expand Down
4 changes: 3 additions & 1 deletion src/display/char-type.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@
(icon-value code :font))

(defun zero-width-char-code-p (code)
(or (<= #x200B code #x200D) (= code #xFEFF)))
(or (<= #x200B code #x200D)
(<= #xFE00 code #xFE0F)
(= code #xFEFF)))

(defun char-type (char)
(let ((code (char-code char)))
Expand Down
9 changes: 5 additions & 4 deletions src/display/physical-line.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -141,10 +141,11 @@
string))
:attribute (case type
((:control :zero-width)
(merge-attribute attribute
(ensure-attribute 'special-char-attribute nil)))
(otherwise
attribute))
(let ((attr (ensure-attribute 'special-char-attribute nil)))
(if attribute
(merge-attribute attribute attr)
attr)))
(otherwise attribute))
:type type
:within-cursor (and attribute
(cursor-attribute-p attribute)))))
Expand Down

0 comments on commit f51036d

Please sign in to comment.