File tree Expand file tree Collapse file tree 1 file changed +35
-0
lines changed Expand file tree Collapse file tree 1 file changed +35
-0
lines changed Original file line number Diff line number Diff line change @@ -35,6 +35,7 @@ let s:save_wrapscan = &wrapscan
35
35
set nowrapscan
36
36
37
37
" Start at the first "msgid" line.
38
+ let wsv = winsaveview ()
38
39
1
39
40
/^msgid\>
40
41
@@ -110,7 +111,41 @@ if search('msgid "\("\n"\)\?\([EW][0-9]\+:\).*\nmsgstr "\("\n"\)\?[^"]\@=\2\@!')
110
111
endif
111
112
endif
112
113
114
+ func ! CountNl (first , last )
115
+ let nl = 0
116
+ for lnum in range (a: first , a: last )
117
+ let nl += count (getline (lnum), " \n " )
118
+ endfor
119
+ return nl
120
+ endfunc
121
+
122
+ " Check that the \n at the end of the msgid line is also present in the msgstr
123
+ " line. Skip over the header.
124
+ /^" MIME-Version:
125
+ while 1
126
+ let lnum = search (' ^msgid\>' )
127
+ if lnum <= 0
128
+ break
129
+ endif
130
+ let strlnum = search (' ^msgstr\>' )
131
+ let end = search (' ^$' )
132
+ if end <= 0
133
+ let end = line (' $' ) + 1
134
+ endif
135
+ let origcount = CountNl (lnum, strlnum - 1 )
136
+ let transcount = CountNl (strlnum, end - 1 )
137
+ " Allow for a few more or less line breaks when there are 2 or more
138
+ if origcount != transcount && (origcount <= 2 || transcount <= 2 )
139
+ echomsg ' Mismatching "\n" in line ' . line (' .' )
140
+ if error == 0
141
+ let error = lnum
142
+ endif
143
+ endif
144
+ endwhile
145
+
113
146
if error == 0
147
+ " If all was OK restore the view.
148
+ call winrestview (wsv)
114
149
echomsg " OK"
115
150
else
116
151
exe error
You can’t perform that action at this time.
0 commit comments