From 22cfd2f2c801524dec74b15ea234b3105424fb4e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jostein=20Kj=C3=B8nigsen?= Date: Wed, 16 Mar 2016 21:44:55 +0100 Subject: [PATCH] Fix actor fontification error Lines would get incorrectly fontified when line contained more than one colon. This closes https://github.com/josteink/wsd-mode/issues/37 --- test-files/fontification-double-colon.wsd | 7 +++++++ wsd-mode.el | 4 ++-- wsd-tests.el | 13 +++++++++++++ 3 files changed, 22 insertions(+), 2 deletions(-) create mode 100644 test-files/fontification-double-colon.wsd diff --git a/test-files/fontification-double-colon.wsd b/test-files/fontification-double-colon.wsd new file mode 100644 index 0000000..96ac74d --- /dev/null +++ b/test-files/fontification-double-colon.wsd @@ -0,0 +1,7 @@ + +title Double colon fontification error (as outligned in github issue 37) + +pc->pc: This line highlight's actor just fine +pc->pc: This line doesn't, because of a double : sign. +pc->pc: But next line is just fine again. + diff --git a/wsd-mode.el b/wsd-mode.el index 21c12cc..dcb287c 100644 --- a/wsd-mode.el +++ b/wsd-mode.el @@ -260,10 +260,10 @@ (wsd-rx-word "as") "\\(.+\\)$"))) - ;; actors in activity staements + ;; actors in activity statements (rx-actors (wsd-rx-lstart (concat "\\([^\n-]+\\)" (regexp-opt wsd-operators3 t) - "\\(.+\\)" + "\\([^:]+\\)" ":.*$"))) ;; actors in activate/deactivate/destroy statements diff --git a/wsd-tests.el b/wsd-tests.el index 86b1a26..aff0137 100755 --- a/wsd-tests.el +++ b/wsd-tests.el @@ -160,6 +160,19 @@ 'font-lock-variable-name-face (face-at-point))))))) +(ert-deftest statement-actors-are-fontified-as-variables () + (let* ((buffer (find-file-read-only "test-files/fontification-double-colon.wsd"))) + ;; double-ensure mode is active + (wsd-mode) + ;; required when running in unit-test runner. + (font-lock-fontify-buffer) + + (while (search-forward "pc" nil t) + (backward-char 1) + (should (eql + 'font-lock-variable-name-face + (face-at-point)))))) + (ert-deftest indentation-reference-document-is-reflowed-correctly () (let* ((buffer (find-file "test-files/indentation-tests.wsd"))) ;; double ensure mode is active