diff --git a/common/decklist.cpp b/common/decklist.cpp index 74cfd294..0993d71f 100644 --- a/common/decklist.cpp +++ b/common/decklist.cpp @@ -542,10 +542,11 @@ bool DeckList::loadFromStream_Plain(QTextStream &in) } // If we have a blank line and it's the _ONLY_ blank line in the paste + // and it follows at least one valid card // Then we assume it means to start the sideboard section of the paste. // If we have the word "Sideboard" appear on any line, then that will // also indicate the start of the sideboard. - if ((line.isEmpty() && blankLines == 1) || line.startsWith("sideboard")) { + if ((line.isEmpty() && blankLines == 1 && okRows > 0) || line.startsWith("sideboard")) { inSideboard = true; continue; // The line isn't actually a card } diff --git a/tests/loading_from_clipboard/loading_from_clipboard_test.cpp b/tests/loading_from_clipboard/loading_from_clipboard_test.cpp index 20576488..f21f610a 100644 --- a/tests/loading_from_clipboard/loading_from_clipboard_test.cpp +++ b/tests/loading_from_clipboard/loading_from_clipboard_test.cpp @@ -228,10 +228,25 @@ TEST(LoadingFromClipboardTest, LotsOfStuffInBulkTesting) ASSERT_EQ(expectedMainboard, decklistBuilder.mainboard()); ASSERT_EQ(expectedSideboard, decklistBuilder.sideboard()); } + +TEST(LoadingFromClipboardTest, CommentsBeforeCardsTesting) +{ + QString *clipboard = new QString("//NAME: Title from Website.com\n" + "\n" + "//Main\n" + "1 test1\n"); + DeckList *decklist = fromClipboard(clipboard); + DecklistBuilder decklistBuilder = DecklistBuilder(); + decklist->forEachCard(decklistBuilder); + CardRows expectedMainboard = CardRows({{"test1", 1}}); + CardRows expectedSideboard = CardRows({}); + ASSERT_EQ(expectedMainboard, decklistBuilder.mainboard()); + ASSERT_EQ(expectedSideboard, decklistBuilder.sideboard()); +} } // namespace int main(int argc, char **argv) { ::testing::InitGoogleTest(&argc, argv); return RUN_ALL_TESTS(); -} \ No newline at end of file +}