aboutsummaryrefslogtreecommitdiffstats
path: root/test/src
diff options
context:
space:
mode:
authorEli Zaretskii2020-09-30 17:33:58 +0300
committerEli Zaretskii2020-09-30 17:33:58 +0300
commita190a446ee2be283dbd48351af507d7c64b1af9e (patch)
tree39dfb497e518ab921bc2c45e8e31f270796f369c /test/src
parent56d6e29d8063552b6a293f67f91ce6967913d928 (diff)
downloademacs-a190a446ee2be283dbd48351af507d7c64b1af9e.tar.gz
emacs-a190a446ee2be283dbd48351af507d7c64b1af9e.zip
Fix 'move-to-column' when invisible text follows a TAB
* src/indent.c (scan_for_column): Accept 2 more arguments, and report through them the position corresponding to PREVCOL. All callers changed. (Fmove_to_column): Use the prev_col's position to test for a TAB instead of assuming that the TAB is just before point (which is false when there's invisible text around). (Bug#43587) * test/src/indent-tests.el: New file.
Diffstat (limited to 'test/src')
-rw-r--r--test/src/indent-tests.el59
1 files changed, 59 insertions, 0 deletions
diff --git a/test/src/indent-tests.el b/test/src/indent-tests.el
new file mode 100644
index 00000000000..7d1a6ce6dc3
--- /dev/null
+++ b/test/src/indent-tests.el
@@ -0,0 +1,59 @@
1;;; indent-tests.el --- tests for src/indent.c -*- lexical-binding:t -*-
2
3;; Copyright (C) 2020 Free Software Foundation, Inc.
4
5;; This file is part of GNU Emacs.
6
7;; This program is free software: you can redistribute it and/or
8;; modify it under the terms of the GNU General Public License as
9;; published by the Free Software Foundation, either version 3 of the
10;; License, or (at your option) any later version.
11;;
12;; This program is distributed in the hope that it will be useful, but
13;; WITHOUT ANY WARRANTY; without even the implied warranty of
14;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15;; General Public License for more details.
16;;
17;; You should have received a copy of the GNU General Public License
18;; along with this program. If not, see `https://www.gnu.org/licenses/'.
19
20;;; Commentary:
21
22;;; Code:
23
24(ert-deftest indent-tests-move-to-column-invis-1tab ()
25 "Test `move-to-column' when a TAB is followed by invisible text."
26 (should
27 (string=
28 (with-temp-buffer
29 (insert "\tLine starting with INVISIBLE text after TAB\n")
30 (add-text-properties 2 21 '(invisible t))
31 (goto-char (point-min))
32 (move-to-column 7 t)
33 (buffer-substring-no-properties 1 8))
34 " ")))
35
36(ert-deftest indent-tests-move-to-column-invis-2tabs ()
37 "Test `move-to-column' when 2 TABs are followed by invisible text."
38 (should
39 (string=
40 (with-temp-buffer
41 (insert "\t\tLine starting with INVISIBLE text after TAB\n")
42 (add-text-properties 3 22 '(invisible t))
43 (goto-char (point-min))
44 (move-to-column 12 t)
45 (buffer-substring-no-properties 1 11))
46 "\t \tLine")))
47
48(ert-deftest indent-tests-move-to-column-invis-between-tabs ()
49 "Test `move-to-column' when 2 TABs are mixed with invisible text."
50 (should
51 (string=
52 (with-temp-buffer
53 (insert "\txxx\tLine starting with INVISIBLE text after TAB\n")
54 (add-text-properties 6 25 '(invisible t))
55 (add-text-properties 2 5 '(invisible t))
56 (goto-char (point-min))
57 (move-to-column 12 t)
58 (buffer-substring-no-properties 1 14))
59 "\txxx \tLine")))