18
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-12-02 02:42:46 +01:00

fix(editor): the anchors section keeps its blank lines and comments, a reason keeps its blanks, a scenery including itself is told

- The section kept for the anchors is written back as it was read: its blank lines and its # comments were dropped before the section
  was looked at.
- The reason of a legacy record is the rest of the line as written, its blanks kept: joined with one blank, a reason of two blanks
  came back changed after a save and a load.
- A file of a scenery including itself, on its own or through others, is told and not read again; before, only the depth of 32
  stopped it.
This commit is contained in:
maj00r
2026-11-29 22:34:35 +01:00
parent 6469b2a57f
commit 9d5e32980f
4 changed files with 53 additions and 14 deletions
+17 -13
View File
@@ -209,13 +209,16 @@ class record
fail(std::format("'{}' isn't a profile of the norms", text));
return norms::profile_id::plk;
}
// the rest of the line as it is written, the blanks between the words kept as one
// the rest of the line as it is written, from its next word to its last, the blanks between the words as they are: joined with one
// blank, a reason of two blanks came back changed after a save and a load
std::string rest()
{
std::string result;
for (; false == done(); ++m_at)
result += (result.empty() ? "" : " ") + std::string{m_words[m_at]};
return result;
if (done())
return {};
auto const first{m_words[m_at]};
auto const last{m_words.back()};
m_at = m_words.size();
return std::string(first.data(), static_cast<std::size_t>(last.data() + last.size() - first.data()));
}
void finish()
{
@@ -425,6 +428,15 @@ read_result read(std::string_view const Text)
continue;
}
record words{text};
// the section kept for the anchors is written back as it was read, its blank lines and its comments too
if (in == section::anchors)
{
if (words.peek() == "end" && words_of(text).size() == 1)
in = section::top;
else
project.anchors.emplace_back(text);
continue;
}
if (words.empty() || words.peek().front() == '#')
continue;
if (false == versioned)
@@ -448,14 +460,6 @@ read_result read(std::string_view const Text)
continue;
}
auto const keyword{words.peek()};
if (in == section::anchors)
{
if (keyword == "end" && words_of(text).size() == 1)
in = section::top;
else
project.anchors.emplace_back(text);
continue;
}
words.next("");
if (in == section::turnouts)
{