Skip to content

Commit 4667be3

Browse files
committed
Fixed doubled space bug.
1 parent 9f81ddc commit 4667be3

File tree

1 file changed

+10
-14
lines changed

1 file changed

+10
-14
lines changed

src/lekhika-addon.cpp

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -154,8 +154,8 @@ void NepaliRomanEngine::keyEvent(const InputMethodEntry &, KeyEvent &keyEvent) {
154154
.toString();
155155
ic->commitString(word + " ");
156156
resetState(state, ic);
157-
state->navigatedInCandidates_ = false; // reset after commit
158-
keyEvent.filterAndAccept(); // Consume
157+
state->navigatedInCandidates_ = false;
158+
keyEvent.filterAndAccept();
159159
return;
160160
}
161161
}
@@ -233,7 +233,7 @@ void NepaliRomanEngine::keyEvent(const InputMethodEntry &, KeyEvent &keyEvent) {
233233
candidateList->candidate(candidateList->cursorIndex())
234234
.text()
235235
.toString();
236-
ic->commitString(word);
236+
ic->commitString(word + " ");
237237
resetState(state, ic);
238238
committed = true;
239239
}
@@ -256,32 +256,29 @@ void NepaliRomanEngine::keyEvent(const InputMethodEntry &, KeyEvent &keyEvent) {
256256
if (committed) {
257257
keyEvent.filterAndAccept();
258258
}
259-
// If nothing committed, key is NOT consumed → reaches app
260259
return;
261260
}
262261

263262
// Space: commit candidate if allowed, else commit buffer or insert space
264263
if (sym == FcitxKey_space) {
265-
if (isCandidateListVisible) {
264+
if (spacecanCommitSuggestions_ && isCandidateListVisible) {
266265
auto candidateList = ic->inputPanel().candidateList();
267-
if (candidateList &&
268-
(spacecanCommitSuggestions_ || state->navigatedInCandidates_) &&
269-
candidateList->cursorIndex() >= 0) {
266+
if (candidateList && candidateList->cursorIndex() >= 0) {
270267
const auto &word =
271268
candidateList->candidate(candidateList->cursorIndex())
272269
.text()
273270
.toString();
274271
ic->commitString(word + " ");
275272
resetState(state, ic);
276273
state->navigatedInCandidates_ = false;
277-
keyEvent.filterAndAccept(); // Consume
274+
// Do NOT consume — let Space reach app for the space
278275
return;
279276
}
280277
}
281278
// Fallback: commit buffer or insert space
282279
if (!state->buffer_.empty()) {
283280
std::string result = transliterator_->transliterate(state->buffer_);
284-
ic->commitString(result + " ");
281+
ic->commitString(result);
285282
#ifdef HAVE_SQLITE3
286283
if (dictionary_ && enableDictionaryLearning_) {
287284
dictionary_->addWord(result);
@@ -291,8 +288,7 @@ void NepaliRomanEngine::keyEvent(const InputMethodEntry &, KeyEvent &keyEvent) {
291288
// Do NOT consume — let Space reach app
292289
return;
293290
} else {
294-
ic->commitString(" ");
295-
// Do NOT consume — let Space reach app
291+
// Do NOT consume — let Space reach app
296292
return;
297293
}
298294
}
@@ -303,7 +299,7 @@ void NepaliRomanEngine::keyEvent(const InputMethodEntry &, KeyEvent &keyEvent) {
303299
ic->commitString(state->buffer_);
304300
resetState(state, ic);
305301
}
306-
keyEvent.filterAndAccept(); // Consume — IME-specific action
302+
keyEvent.filterAndAccept();
307303
return;
308304
}
309305

@@ -408,7 +404,7 @@ void NepaliRomanEngine::updatePreedit(InputContext *ic) {
408404
size_t cursor_in_preview_bytes = preview_before_cursor.length();
409405
preedit.append(preview_full, TextFormatFlag::Underline);
410406
preedit.setCursor(cursor_in_preview_bytes);
411-
aux.append(state->buffer_);
407+
aux.append(state->buffer_ + "" + preview_before_cursor);
412408
}
413409

414410
ic->inputPanel().setClientPreedit(preedit);

0 commit comments

Comments
 (0)