mirror of
https://github.com/Palm1r/QodeAssist.git
synced 2026-07-12 22:31:19 -04:00
fix: Found and fix review mistakes
This commit is contained in:
@@ -52,11 +52,31 @@ void TomlWriter::writeTableHeader(const QString &name)
|
||||
m_out += QLatin1String("]\n");
|
||||
}
|
||||
|
||||
namespace {
|
||||
|
||||
bool isBareKey(const QString &key)
|
||||
{
|
||||
if (key.isEmpty())
|
||||
return false;
|
||||
for (QChar c : key) {
|
||||
if (!c.isLetterOrNumber() && c != QLatin1Char('_') && c != QLatin1Char('-'))
|
||||
return false;
|
||||
if (c.unicode() > 0x7f)
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
void TomlWriter::writeKeyPrefix(const QString &key)
|
||||
{
|
||||
m_out += key;
|
||||
if (m_keyColumnWidth > key.size())
|
||||
m_out += QString(m_keyColumnWidth - key.size(), QLatin1Char(' '));
|
||||
const QString rendered = isBareKey(key)
|
||||
? key
|
||||
: QLatin1Char('"') + escapeBasic(key) + QLatin1Char('"');
|
||||
m_out += rendered;
|
||||
if (m_keyColumnWidth > rendered.size())
|
||||
m_out += QString(m_keyColumnWidth - rendered.size(), QLatin1Char(' '));
|
||||
m_out += QLatin1String(" = ");
|
||||
}
|
||||
|
||||
|
||||
@@ -22,8 +22,8 @@ public:
|
||||
void setKeyColumnWidth(int width) { m_keyColumnWidth = width; }
|
||||
|
||||
void writeBlankLine();
|
||||
void writeComment(const QString &line); // "# line\n"
|
||||
void writeTableHeader(const QString &name); // "[name]\n"
|
||||
void writeComment(const QString &line);
|
||||
void writeTableHeader(const QString &name);
|
||||
|
||||
void writeString(const QString &key, const QString &value);
|
||||
void writeBool(const QString &key, bool value);
|
||||
|
||||
Reference in New Issue
Block a user