Show More
@@ -246,14 +246,16 b' def _scantemplate(tmpl, start, stop, quo' | |||||
246 | except error.ParseError as inst: |
|
246 | except error.ParseError as inst: | |
247 | if len(inst.args) > 1: # has location |
|
247 | if len(inst.args) > 1: # has location | |
248 | loc = inst.args[1] |
|
248 | loc = inst.args[1] | |
249 | # TODO: Opportunity for improvement! If there is a newline in the |
|
249 | # Offset the caret location by the number of newlines before the | |
250 | # template, this hint does not point to the right place, so skip. |
|
250 | # location of the error, since we will replace one-char newlines | |
251 | if '\n' not in tmpl: |
|
251 | # with the two-char literal r'\n'. | |
252 | # We want the caret to point to the place in the template that |
|
252 | offset = tmpl[:loc].count('\n') | |
253 | # failed to parse, but in a hint we get a open paren at the |
|
253 | tmpl = tmpl.replace('\n', br'\n') | |
254 | # start. Therefore, we print "loc" spaces (instead of "loc - 1") |
|
254 | # We want the caret to point to the place in the template that | |
255 | # to line up the caret with the location of the error. |
|
255 | # failed to parse, but in a hint we get a open paren at the | |
256 | inst.hint = tmpl + '\n' + ' ' * (loc) + '^ ' + _('here') |
|
256 | # start. Therefore, we print "loc" spaces (instead of "loc - 1") | |
|
257 | # to line up the caret with the location of the error. | |||
|
258 | inst.hint = tmpl + '\n' + ' ' * (loc + offset) + '^ ' + _('here') | |||
257 | raise |
|
259 | raise | |
258 | yield ('end', None, pos) |
|
260 | yield ('end', None, pos) | |
259 |
|
261 |
@@ -2304,6 +2304,8 b' multi-line template with error' | |||||
2304 | > {shortest(node} |
|
2304 | > {shortest(node} | |
2305 | > line4\nline5' |
|
2305 | > line4\nline5' | |
2306 | hg: parse error at 28: unexpected token: end |
|
2306 | hg: parse error at 28: unexpected token: end | |
|
2307 | (line 1\nline2\n{shortest(node}\nline4\nline5 | |||
|
2308 | ^ here) | |||
2307 | [255] |
|
2309 | [255] | |
2308 |
|
2310 | |||
2309 | $ cd .. |
|
2311 | $ cd .. |
General Comments 0
You need to be logged in to leave comments.
Login now