Skip to content

Commit

Permalink
fix(navigator): wrong spans after selection
Browse files Browse the repository at this point in the history
  • Loading branch information
ksqsf committed Nov 17, 2024
1 parent c7ab639 commit c3e30a4
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/rime/gear/navigator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@ Navigator::Navigator(const Ticket& ticket)
Config* config = engine_->schema()->config();
LoadConfig(config, "navigator", Horizontal);
LoadConfig(config, "navigator/vertical", Vertical);

engine_->context()->select_notifier().connect(
[this](Context* ctx) { OnSelect(ctx); });
}

ProcessResult Navigator::ProcessKeyEvent(const KeyEvent& key_event) {
Expand All @@ -74,6 +77,10 @@ ProcessResult Navigator::ProcessKeyEvent(const KeyEvent& key_event) {
FallbackOptions::All);
}

void Navigator::OnSelect(Context* ctx) {
spans_.Clear();
}

bool Navigator::LeftBySyllable(Context* ctx) {
BeginMove(ctx);
size_t confirmed_pos = ctx->composition().GetConfirmedPosition();
Expand All @@ -84,6 +91,7 @@ bool Navigator::LeftBySyllable(Context* ctx) {
bool Navigator::LeftByChar(Context* ctx) {
BeginMove(ctx);
MoveLeft(ctx) || GoToEnd(ctx);
spans_.Clear();
return true;
}

Expand All @@ -107,6 +115,7 @@ bool Navigator::RightBySyllable(Context* ctx) {
bool Navigator::RightByChar(Context* ctx) {
BeginMove(ctx);
MoveRight(ctx) || GoHome(ctx);
spans_.Clear();
return true;
}

Expand Down
1 change: 1 addition & 0 deletions src/rime/gear/navigator.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ class Navigator : public Processor, public KeyBindingProcessor<Navigator, 2> {
bool MoveRight(Context* ctx);
bool GoHome(Context* ctx);
bool GoToEnd(Context* ctx);
void OnSelect(Context*);

string input_;
Spans spans_;
Expand Down

0 comments on commit c3e30a4

Please sign in to comment.