Skip to content

Commit

Permalink
better string conversion
Browse files Browse the repository at this point in the history
  • Loading branch information
eteran committed Jan 11, 2025
1 parent d1ed580 commit 26ca520
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/Preferences.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,35 +95,35 @@ std::optional<LanguageMode> readLanguageModeYaml(const YAML::Node &language) {
const YAML::Node value = it->second;

if (key == "name") {
lm.name = QString::fromUtf8(value.as<std::string>().c_str());
lm.name = QString::fromStdString(value.as<std::string>());
} else if (key == "delimiters") {
lm.delimiters = QString::fromUtf8(value.as<std::string>().c_str());
lm.delimiters = QString::fromStdString(value.as<std::string>());
} else if (key == "tab_distance") {
lm.tabDist = value.as<int>();
} else if (key == "em_tab_distance") {
lm.emTabDist = value.as<int>();
} else if (key == "insert_tabs") {
lm.insertTabs = value.as<bool>();
} else if (key == "regex") {
lm.recognitionExpr = QString::fromUtf8(value.as<std::string>().c_str());
lm.recognitionExpr = QString::fromStdString(value.as<std::string>());
} else if (key == "wrap") {
auto string_val = QString::fromUtf8(value.as<std::string>().c_str());
auto string_val = QString::fromStdString(value.as<std::string>());
auto it = std::find(std::begin(AutoWrapTypes), std::end(AutoWrapTypes), string_val);
if (it == std::end(AutoWrapTypes)) {
Raise<ModeError>(tr("unrecognized wrap style"));
}

lm.wrapStyle = static_cast<WrapStyle>(it - std::begin(AutoWrapTypes));
} else if (key == "indent") {
auto string_val = QString::fromUtf8(value.as<std::string>().c_str());
auto string_val = QString::fromStdString(value.as<std::string>());
auto it = std::find(std::begin(AutoIndentTypes), std::end(AutoIndentTypes), string_val);
if (it == std::end(AutoIndentTypes)) {
Raise<ModeError>(tr("unrecognized indent style"));
}

lm.indentStyle = static_cast<IndentStyle>(it - std::begin(AutoIndentTypes));
} else if (key == "default_tips") {
lm.defTipsFile = QString::fromUtf8(value.as<std::string>().c_str());
lm.defTipsFile = QString::fromStdString(value.as<std::string>());
} else if (key == "extensions") {
QStringList extensions;
for (size_t i = 0; i < value.size(); i++) {
Expand Down

0 comments on commit 26ca520

Please sign in to comment.