Skip to content

Commit

Permalink
Allow use [词组] in extra dict text format
Browse files Browse the repository at this point in the history
  • Loading branch information
wengxt committed Nov 19, 2024
1 parent 003f74d commit 86d1651
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
3 changes: 2 additions & 1 deletion src/libime/table/tablebaseddictionary.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1082,7 +1082,8 @@ size_t TableBasedDictionary::loadExtra(std::istream &in, TableFormat format) {
continue;
}
boost::trim_if(buf, isSpaceCheck);
if (buf == ExtraDictPhraseMark) {
if (buf == strConst[0][STR_PHRASE] ||
buf == strConst[1][STR_PHRASE]) {
state = ExtraDictState::Phrase;
continue;
}
Expand Down
15 changes: 13 additions & 2 deletions test/testtable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@ void testEscape() {
FCITX_ASSERT(out.str() == expect) << out.str();
}

void testOneMatchingWord() {
void testExtraDict() {
libime::TableBasedDictionary table;
{
std::string test = "KeyCode=abcdefghijklmnopqrstuvwxy\n"
Expand Down Expand Up @@ -361,9 +361,20 @@ void testOneMatchingWord() {
FCITX_ASSERT(extraIndex == 1);
table.saveExtra(extraIndex, std::cout, libime::TableFormat::Text);
testMatchIndex(table, "xynn", 4);

// Test load [词组]
table.removeAllExtra();
{
std::string test = "[词组]\n统计局\n";
std::stringstream ss(test);
extraIndex = table.loadExtra(ss, TableFormat::Text);
}
FCITX_ASSERT(extraIndex == 0);
table.saveExtra(extraIndex, std::cout, libime::TableFormat::Text);
testMatchIndex(table, "xynn", 3);
}

void testExtraDict() {
void testOneMatchingWord() {

std::string test = "KeyCode=abcdefghijklmnopqrstuvwxy\n"
"Length=4\n"
Expand Down

0 comments on commit 86d1651

Please sign in to comment.