Monday, June 29, 2020

Re: An interesting little poser [PS]

[sorry for the belated reply.]

On 2020-06-27 22:46, Chris Jones wrote:
> Not sure if it's some kind of corner case or this little
> experimented has unearthed a bug in Vim's regex logic...

Not a bug in the regex parser. See further diagnosis:

> On Mon, Jun 22, 2020 at 09:40:38PM EDT, Tim Chase wrote:
> > " make all the footnotes on one line
> > $?^$?+,$g/^\[\@!.*\n\[\@!/,/\n\[\|\%$/j

The problem lies here. If you remove the second half of the range

:$?^$?+,$g/^\[\@!.*\n\[\@!/

vim is finding lines that need to be joined. However in your example

> The problem occurs for instance with the following example file:
> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
[snip]
> [36]
> Ullam consequatur.
> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

that last line ends in a newline that isn't followed by a \[ so my
regex thinks it should join this. But then when it goes to find the
ending of the range to join, it looks for something slightly
different.

Try changing that line from

$?^$?+,$g/^\[\@!.*\n\[\@!/,/\n\[\|\%$/j

to

$?^$?+,$g/^\[\@!.*\n\[\@!./,/\n\[\|\%$/j

(adding that "." after the "make sure a literal [ doesn't happen
here") to ensure that there's something for the line to join.

Seems to resolve the issue for me without breaking my other
test-cases that I threw at it.

You might still get "errors" (more like complaints) if you have a
file containing 0 multi-line footnotes, telling you "Pattern not
found". But that should be ignorable because there simply weren't any
footnote lines for it to join together.

-tim



--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/20200629143403.1fc5d1f7%40bigbox.attlocal.net.

No comments: