Skip to content

Commit

Permalink
avoid commit twice
Browse files Browse the repository at this point in the history
  • Loading branch information
eagleoflqj committed Nov 30, 2023
1 parent 12da72c commit 671c565
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 14 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:
- name: Lint
run: |
find . -name '*.cpp' -o -name '*.h' | xargs clang-format -Werror --dry-run || { echo Please lint your code by '"'"find . -name '*.cpp' -o -name '*.h' | xargs clang-format -i"'"'.; false; }
find src test -name '*.cpp' -o -name '*.h' | xargs clang-format -Werror --dry-run || { echo Please lint your code by '"'"find src test -name '*.cpp' -o -name '*.h' | xargs clang-format -i"'"'.; false; }
- name: Build
run: |
Expand Down
23 changes: 12 additions & 11 deletions src/hallelujah.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,16 @@ class HallelujahCandidateWord : public CandidateWord {
HallelujahCandidateWord(HallelujahState *state, std::string word,
std::string candidate)
: state_(state), word_(word) {
Text text;
text.append(candidate);
setText(text);
setText(Text(candidate));
}

void select(InputContext *inputContext) const override {
inputContext->commitString(word_);
state_->reset(inputContext);
}

std::string getWord() const { return word_; }

private:
HallelujahState *state_;
std::string word_;
Expand Down Expand Up @@ -121,11 +121,15 @@ void HallelujahState::keyEvent(KeyEvent &event) {
}
if (key.check(FcitxKey_space) || key.check(FcitxKey_Return)) {
event.filterAndAccept();
candidateList->candidate(candidateList->cursorIndex()).select(ic_);
std::string word =
dynamic_cast<const HallelujahCandidateWord &>(
candidateList->candidate(candidateList->cursorIndex()))
.getWord();
if (key.check(FcitxKey_space)) {
ic_->commitString(" ");
word += " ";
}
return;
ic_->commitString(word);
return reset(ic_);
}
if (key.check(FcitxKey_Down) || key.check(FcitxKey_Up)) {
auto cm = candidateList->toCursorMovable();
Expand Down Expand Up @@ -230,8 +234,7 @@ HallelujahEngine::HallelujahEngine(Instance *instance)

HallelujahEngine::~HallelujahEngine() { factory_.unregister(); }

void HallelujahEngine::activate(const InputMethodEntry &entry,
InputContextEvent &event) {
void HallelujahEngine::activate(const InputMethodEntry &, InputContextEvent &) {
spell();
}

Expand Down Expand Up @@ -320,9 +323,7 @@ void HallelujahEngine::loadPinyin() {
}
}

void HallelujahEngine::keyEvent(const InputMethodEntry &entry,
KeyEvent &keyEvent) {
FCITX_UNUSED(entry);
void HallelujahEngine::keyEvent(const InputMethodEntry &, KeyEvent &keyEvent) {
if (keyEvent.isRelease() || keyEvent.key().states()) {
return;
}
Expand Down
4 changes: 2 additions & 2 deletions test/testhallelujah.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ using namespace fcitx;
std::vector<std::pair<std::vector<std::string>, std::vector<std::string>>>
expectedCommit{
{{"a", "4"}, {"at"}},
{{"a", "space"}, {"a", " "}},
{{"a", "space"}, {"a "}},
{{"a", "Return"}, {"a"}},
{{"a", "Down", "space"}, {"as", " "}},
{{"a", "Down", "space"}, {"as "}},
{{"a", "Up", "Return"}, {"also"}},
{{"a", "Escape"}, {}},
{{"a", "b", "BackSpace", "Return"}, {"a"}},
Expand Down

0 comments on commit 671c565

Please sign in to comment.