FakeVim: Only drop full-line comments

This is not what real vim does, but :help comments looks scary,
we don't support more complex scripts anyway, and full-line
comments at least allow some commenting.

Fixes: QTCREATORBUG-26254
Change-Id: I9018d06d2a929fad6d3d301240928b6a8b109710
Reviewed-by: Lukas Holecek <hluk@email.cz>
Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
hjk
2021-10-13 08:32:06 +02:00
parent 6dd66e012b
commit e1a69fccb1

View File

@@ -6598,13 +6598,12 @@ bool FakeVimHandler::Private::handleExSourceCommand(const ExCommand &cmd)
while (!file.atEnd() || !line.isEmpty()) {
QByteArray nextline = !file.atEnd() ? file.readLine() : QByteArray();
// remove comment
int i = nextline.lastIndexOf('"');
if (i != -1)
nextline = nextline.remove(i, nextline.size() - i);
nextline = nextline.trimmed();
// remove full line comment. for being precise, check :help comment in vim.
if (nextline.startsWith('"'))
continue;
// multi-line command?
if (nextline.startsWith('\\')) {
line += nextline.mid(1);