FakeVim: Assume UTF-8 for source also on Windows by default

... but make it configurable.

Fixes: QTCREATORBUG-29320
Change-Id: Ib377c78e51afb7d06167c66306250a281aa9279c
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
hjk
2023-07-04 08:18:23 +02:00
parent 1d1eb9c3a2
commit 418482b3e2
3 changed files with 6 additions and 2 deletions

View File

@@ -94,6 +94,7 @@ FakeVimSettings::FakeVimSettings()
setup(&showCmd, true, "ShowCmd", "sc", Tr::tr("Show partial command")); setup(&showCmd, true, "ShowCmd", "sc", Tr::tr("Show partial command"));
setup(&relativeNumber, false, "RelativeNumber", "rnu", Tr::tr("Show line numbers relative to cursor")); setup(&relativeNumber, false, "RelativeNumber", "rnu", Tr::tr("Show line numbers relative to cursor"));
setup(&blinkingCursor, false, "BlinkingCursor", "bc", Tr::tr("Blinking cursor")); setup(&blinkingCursor, false, "BlinkingCursor", "bc", Tr::tr("Blinking cursor"));
setup(&systemEncoding, false, "SystemEncoding", {}, Tr::tr("Use system encoding for :source"));
setup(&scrollOff, 0, "ScrollOff", "so", Tr::tr("Scroll offset:")); setup(&scrollOff, 0, "ScrollOff", "so", Tr::tr("Scroll offset:"));
setup(&backspace, "indent,eol,start", setup(&backspace, "indent,eol,start",
"Backspace", "bs", Tr::tr("Backspace:")); "Backspace", "bs", Tr::tr("Backspace:"));
@@ -149,7 +150,8 @@ FakeVimSettings::FakeVimSettings()
showCmd, showCmd,
startOfLine, startOfLine,
passKeys, passKeys,
blinkingCursor blinkingCursor,
HostOsInfo::isWindowsHost() ? LayoutItem(systemEncoding) : empty
}, },
Column { Column {
incSearch, incSearch,

View File

@@ -151,6 +151,7 @@ public:
FvBoolAspect emulateSurround; FvBoolAspect emulateSurround;
FvBoolAspect blinkingCursor; FvBoolAspect blinkingCursor;
FvBoolAspect systemEncoding;
private: private:
void setup(FvBaseAspect *aspect, const QVariant &value, void setup(FvBaseAspect *aspect, const QVariant &value,

View File

@@ -6625,7 +6625,8 @@ bool FakeVimHandler::Private::handleExSourceCommand(const ExCommand &cmd)
} else if (!line.isEmpty() && !inFunction) { } else if (!line.isEmpty() && !inFunction) {
//qDebug() << "EXECUTING: " << line; //qDebug() << "EXECUTING: " << line;
ExCommand cmd; ExCommand cmd;
QString commandLine = QString::fromLocal8Bit(line); QString commandLine = s.systemEncoding() ? QString::fromLocal8Bit(line)
: QString::fromUtf8(line);
while (parseExCommand(&commandLine, &cmd)) { while (parseExCommand(&commandLine, &cmd)) {
if (!handleExCommandHelper(cmd)) if (!handleExCommandHelper(cmd))
break; break;