@@ -154,6 +154,43 @@ function GetRustIndent(lnum)
154
154
return indent (prevlinenum)
155
155
endif
156
156
157
+ if ! has (" patch-7.4.355" )
158
+ " cindent before 7.4.355 doesn't do the module scope well at all; e.g.::
159
+ "
160
+ " static FOO : &'static [bool] = [
161
+ " true,
162
+ " false,
163
+ " false,
164
+ " true,
165
+ " ];
166
+ "
167
+ " uh oh, next statement is indented further!
168
+
169
+ " Note that this does *not* apply the line continuation pattern properly;
170
+ " that's too hard to do correctly for my liking at present, so I'll just
171
+ " start with these two main cases (square brackets and not returning to
172
+ " column zero)
173
+
174
+ call cursor (a: lnum , 1 )
175
+ if searchpair (' {\|(' , ' ' , ' }\|)' , ' nbW' ,
176
+ \ ' s:is_string_comment(line("."), col("."))' ) == 0
177
+ if searchpair (' \[' , ' ' , ' \]' , ' nbW' ,
178
+ \ ' s:is_string_comment(line("."), col("."))' ) == 0
179
+ " Global scope, should be zero
180
+ return 0
181
+ else
182
+ " At the module scope, inside square brackets only
183
+ " if getline(a:lnum)[0] == ']' || search('\[', '', '\]', 'nW') == a:lnum
184
+ if line = ~ " ^\\ s*]"
185
+ " It's the closing line, dedent it
186
+ return 0
187
+ else
188
+ return &shiftwidth
189
+ endif
190
+ endif
191
+ endif
192
+ endif
193
+
157
194
" Fall back on cindent, which does it mostly right
158
195
return cindent (a: lnum )
159
196
endfunction
0 commit comments