Skip to content

Commit

Permalink
Merge pull request #105 from openvanilla/dev/marking-fine-tunes
Browse files Browse the repository at this point in the history
Put cursor at the back after marking backwards
  • Loading branch information
zonble authored Jan 15, 2024
2 parents c09a368 + 27b8266 commit 33afa98
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/KeyHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,14 @@ bool KeyHandler::handle(Key key, McBopomofo::InputState* state,
if (marking->acceptable) {
userPhraseAdder_->addUserPhrase(marking->reading, marking->markedText);
onAddNewPhrase_(marking->markedText);

// If the cursor was at the end of the buffer when the marking started,
// move back.
if (marking->markStartGridCursorIndex == grid_.length() &&
grid_.cursor() < marking->markStartGridCursorIndex) {
grid_.setCursor(grid_.length());
}

stateCallback(buildInputtingState());
} else {
errorCallback();
Expand Down Expand Up @@ -571,7 +579,7 @@ bool KeyHandler::handleTabKey(Key key, McBopomofo::InputState* state,
errorCallback();
return true;
}
Formosa::Gramambular2::ReadingGrid::NodePtr currentNode = *nodeIter;
const Formosa::Gramambular2::ReadingGrid::NodePtr& currentNode = *nodeIter;

size_t currentIndex = 0;
if (!currentNode->isOverridden()) {
Expand Down Expand Up @@ -999,7 +1007,7 @@ void KeyHandler::pinNode(
if (nodeIter == latestWalk_.nodes.cend()) {
return;
}
Formosa::Gramambular2::ReadingGrid::NodePtr currentNode = *nodeIter;
const Formosa::Gramambular2::ReadingGrid::NodePtr& currentNode = *nodeIter;

if (currentNode != nullptr &&
currentNode->currentUnigram().score() > kNoOverrideThreshold) {
Expand Down

0 comments on commit 33afa98

Please sign in to comment.