1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
|
To: vim_dev@googlegroups.com
Subject: Patch 8.1.0083
Fcc: outbox
From: Bram Moolenaar <Bram@moolenaar.net>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
------------
Patch 8.1.0083
Problem: "is" and "as" have trouble with quoted punctuation.
Solution: Check for punctuation before a quote. (Jason Franklin)
Files: src/search.c, src/testdir/test_textobjects.vim
*** ../vim-8.1.0082/src/search.c 2018-05-22 17:50:38.679980719 +0200
--- src/search.c 2018-06-19 18:19:14.194486159 +0200
***************
*** 2707,2716 ****
}
/*
! * findsent(dir, count) - Find the start of the next sentence in direction
! * "dir" Sentences are supposed to end in ".", "!" or "?" followed by white
! * space or a line break. Also stop at an empty line.
! * Return OK if the next sentence was found.
*/
int
findsent(int dir, long count)
--- 2707,2717 ----
}
/*
! * Find the start of the next sentence, searching in the direction specified
! * by the "dir" argument. The cursor is positioned on the start of the next
! * sentence when found. If the next sentence is found, return OK. Return FAIL
! * otherwise. See ":h sentence" for the precise definition of a "sentence"
! * text object.
*/
int
findsent(int dir, long count)
***************
*** 2758,2783 ****
else if (dir == BACKWARD)
decl(&pos);
! /* go back to the previous non-blank char */
found_dot = FALSE;
! while ((c = gchar_pos(&pos)) == ' ' || c == '\t' ||
! (dir == BACKWARD && vim_strchr((char_u *)".!?)]\"'", c) != NULL))
{
! if (vim_strchr((char_u *)".!?", c) != NULL)
! {
! /* Only skip over a '.', '!' and '?' once. */
! if (found_dot)
! break;
found_dot = TRUE;
! }
! if (decl(&pos) == -1)
break;
! /* when going forward: Stop in front of empty line */
! if (LINEEMPTY(pos.lnum) && dir == FORWARD)
! {
! incl(&pos);
! goto found;
! }
}
/* remember the line where the search started */
--- 2759,2783 ----
else if (dir == BACKWARD)
decl(&pos);
! // go back to the previous non-white non-punctuation character
found_dot = FALSE;
! while (c = gchar_pos(&pos), VIM_ISWHITE(c)
! || vim_strchr((char_u *)".!?)]\"'", c) != NULL)
{
! tpos = pos;
! if (decl(&tpos) == -1 || (LINEEMPTY(tpos.lnum) && dir == FORWARD))
! break;
!
! if (found_dot)
! break;
! if (vim_strchr((char_u *) ".!?", c) != NULL)
found_dot = TRUE;
!
! if (vim_strchr((char_u *) ")]\"'", c) != NULL
! && vim_strchr((char_u *) ".!?)]\"'", gchar_pos(&tpos)) == NULL)
break;
!
! decl(&pos);
}
/* remember the line where the search started */
*** ../vim-8.1.0082/src/testdir/test_textobjects.vim 2018-02-09 18:06:35.000000000 +0100
--- src/testdir/test_textobjects.vim 2018-06-19 18:16:20.911420342 +0200
***************
*** 165,167 ****
--- 165,242 ----
norm it
q!
endfunc
+
+ func Test_sentence()
+ enew!
+ call setline(1, 'A sentence. A sentence? A sentence!')
+
+ normal yis
+ call assert_equal('A sentence.', @")
+ normal yas
+ call assert_equal('A sentence. ', @")
+
+ normal )
+
+ normal yis
+ call assert_equal('A sentence?', @")
+ normal yas
+ call assert_equal('A sentence? ', @")
+
+ normal )
+
+ normal yis
+ call assert_equal('A sentence!', @")
+ normal yas
+ call assert_equal(' A sentence!', @")
+
+ normal 0
+ normal 2yis
+ call assert_equal('A sentence. ', @")
+ normal 3yis
+ call assert_equal('A sentence. A sentence?', @")
+ normal 2yas
+ call assert_equal('A sentence. A sentence? ', @")
+
+ %delete _
+ endfunc
+
+ func Test_sentence_with_quotes()
+ enew!
+ call setline(1, 'A "sentence." A sentence.')
+
+ normal yis
+ call assert_equal('A "sentence."', @")
+ normal yas
+ call assert_equal('A "sentence." ', @")
+
+ normal )
+
+ normal yis
+ call assert_equal('A sentence.', @")
+ normal yas
+ call assert_equal(' A sentence.', @")
+
+ %delete _
+ endfunc
+
+ func! Test_sentence_with_cursor_on_delimiter()
+ enew!
+ call setline(1, "A '([sentence.])' A sentence.")
+
+ normal! 15|yis
+ call assert_equal("A '([sentence.])'", @")
+ normal! 15|yas
+ call assert_equal("A '([sentence.])' ", @")
+
+ normal! 16|yis
+ call assert_equal("A '([sentence.])'", @")
+ normal! 16|yas
+ call assert_equal("A '([sentence.])' ", @")
+
+ normal! 17|yis
+ call assert_equal("A '([sentence.])'", @")
+ normal! 17|yas
+ call assert_equal("A '([sentence.])' ", @")
+
+ %delete _
+ endfunc
*** ../vim-8.1.0082/src/version.c 2018-06-19 17:49:20.300015350 +0200
--- src/version.c 2018-06-19 18:27:12.611837877 +0200
***************
*** 763,764 ****
--- 763,766 ----
{ /* Add new patch number below this line */
+ /**/
+ 83,
/**/
--
From "know your smileys":
y:-) Bad toupee
/// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\ an exciting new programming language -- http://www.Zimbu.org ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
|