Skip to content

Commit 8e2826a

Browse files
committed
feat(context): allow composing with zero input
let IsComposing = either input or composition is non-empty.
1 parent dd6af3d commit 8e2826a

File tree

3 files changed

+13
-15
lines changed

3 files changed

+13
-15
lines changed

src/rime/composition.cc

-3
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,6 @@ bool Composition::HasFinishedComposition() const {
2424
Preedit Composition::GetPreedit(const string& full_input, size_t caret_pos,
2525
const string& caret) const {
2626
Preedit preedit;
27-
if (empty()) {
28-
return preedit;
29-
}
3027
preedit.caret_pos = string::npos;
3128
size_t start = 0;
3229
size_t end = 0;

src/rime/context.cc

+2-2
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ string Context::GetScriptText() const {
3232
return composition_.GetScriptText();
3333
}
3434

35-
static const string kCaretSymbol("\xe2\x80\xb8");
35+
static const string kCaretSymbol("\xe2\x80\xb8"); // U+2038 ‸ CARET
3636

3737
string Context::GetSoftCursor() const {
3838
return get_option("soft_cursor") ? kCaretSymbol : string();
@@ -43,7 +43,7 @@ Preedit Context::GetPreedit() const {
4343
}
4444

4545
bool Context::IsComposing() const {
46-
return !input_.empty();
46+
return !input_.empty() || !composition_.empty();
4747
}
4848

4949
bool Context::HasMenu() const {

src/rime/switcher.cc

+11-10
Original file line numberDiff line numberDiff line change
@@ -114,17 +114,17 @@ void Switcher::HighlightNextSchema() {
114114
```yaml
115115
schema_list:
116116
- case: [mode/wubi, mode/wubi_pinyin]
117-
schema: wubi_pinyin
117+
schema: wubi_pinyin
118118
- case: [mode/wubi]
119-
schema: wubi86
120-
- case: [mode/default]
121-
schema: pinyin
119+
schema: wubi86
120+
- case: [mode/default]
121+
schema: pinyin
122122
123-
mode:
124-
wubi: false
125-
wubi_pinyin: false
126-
default: true
127-
```
123+
mode:
124+
wubi: false
125+
wubi_pinyin: false
126+
default: true
127+
```
128128
*/
129129

130130
static an<ConfigValue> ParseSchemaListEntry(Config* config,
@@ -224,7 +224,8 @@ void Switcher::OnSelect(Context* ctx) {
224224
void Switcher::RefreshMenu() {
225225
Composition& comp = context_->composition();
226226
if (comp.empty()) {
227-
context_->set_input(" "); // make context_->IsComposing() == true
227+
// no longer need this to make context_->IsComposing() == true
228+
// context_->set_input(" ");
228229
Segment seg(0, 0); // empty range
229230
seg.prompt = caption_;
230231
comp.AddSegment(seg);

0 commit comments

Comments
 (0)