anufrievroman / vim-angry-reviewer

Vim plugin for style correction for academic writing and scientific papers

Home Page:https://www.angryreviewer.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Single quotes can mess up command

davidlowryduda opened this issue · comments

If we have the simple file

isn't it?

And we call :AngryReviewer, we get the error

Error detected while processing function AngryReviewer[1154]..function AngryReviewer:
line 1154:
Traceback (most recent call last):
  File "<string>", line 1147, in <module>
vim.error: Vim(call):E722: Missing comma in Dictionary: t.'}], "a")

The problem is happening in the line

vim.command('call setqflist([{"bufnr": bufnr(""), "lnum": '+lnum+', "text": \''+qfitem+'\'}], "a")')

when the quicklist is being constructed. In particular, the problem is with "text": \''+qfitem+'\'. When qfitem has single quotes in it, like the error message for isn't, the string passed to vim isn't the desired string. In this particular case, the complete inner commend passed to vim.command() is

call setqflist([{"bufnr": bufnr(""), "lnum": 3, "text": 'Most academic journals prefer is not instead of isn't.'}], "a"

The single quote in isn' ends the quote, and then there is a dangling t.', which is what the error complains about. Unfortunately, some other responses include double quotes.

I'll make a pull request.

commented

Thank you for the bag report and the fix. It's interesting! For me, actually, there is no such error and single quotes pass fine. I use neovim though. I'll look into it today!

Edit: ah, no, by bad, you are right, and your fix works well! Thank you!