Skip to content

Commit 86d1651

Browse files
committed
Allow use [词组] in extra dict text format
1 parent 003f74d commit 86d1651

File tree

2 files changed

+15
-3
lines changed

2 files changed

+15
-3
lines changed

src/libime/table/tablebaseddictionary.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -1082,7 +1082,8 @@ size_t TableBasedDictionary::loadExtra(std::istream &in, TableFormat format) {
10821082
continue;
10831083
}
10841084
boost::trim_if(buf, isSpaceCheck);
1085-
if (buf == ExtraDictPhraseMark) {
1085+
if (buf == strConst[0][STR_PHRASE] ||
1086+
buf == strConst[1][STR_PHRASE]) {
10861087
state = ExtraDictState::Phrase;
10871088
continue;
10881089
}

test/testtable.cpp

+13-2
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,7 @@ void testEscape() {
321321
FCITX_ASSERT(out.str() == expect) << out.str();
322322
}
323323

324-
void testOneMatchingWord() {
324+
void testExtraDict() {
325325
libime::TableBasedDictionary table;
326326
{
327327
std::string test = "KeyCode=abcdefghijklmnopqrstuvwxy\n"
@@ -361,9 +361,20 @@ void testOneMatchingWord() {
361361
FCITX_ASSERT(extraIndex == 1);
362362
table.saveExtra(extraIndex, std::cout, libime::TableFormat::Text);
363363
testMatchIndex(table, "xynn", 4);
364+
365+
// Test load [词组]
366+
table.removeAllExtra();
367+
{
368+
std::string test = "[词组]\n统计局\n";
369+
std::stringstream ss(test);
370+
extraIndex = table.loadExtra(ss, TableFormat::Text);
371+
}
372+
FCITX_ASSERT(extraIndex == 0);
373+
table.saveExtra(extraIndex, std::cout, libime::TableFormat::Text);
374+
testMatchIndex(table, "xynn", 3);
364375
}
365376

366-
void testExtraDict() {
377+
void testOneMatchingWord() {
367378

368379
std::string test = "KeyCode=abcdefghijklmnopqrstuvwxy\n"
369380
"Length=4\n"

0 commit comments

Comments
 (0)