From e1a69fccb15a87ffc637898cf2248358edb01258 Mon Sep 17 00:00:00 2001 From: hjk Date: Wed, 13 Oct 2021 08:32:06 +0200 Subject: [PATCH] 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 Reviewed-by: hjk --- src/plugins/fakevim/fakevimhandler.cpp | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/plugins/fakevim/fakevimhandler.cpp b/src/plugins/fakevim/fakevimhandler.cpp index ae9cfc173f2..f0ab3becb03 100644 --- a/src/plugins/fakevim/fakevimhandler.cpp +++ b/src/plugins/fakevim/fakevimhandler.cpp @@ -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);