Skip to content

Commit

Permalink
fix: selection reason should be ui event when clicking (#359)
Browse files Browse the repository at this point in the history
  • Loading branch information
LucasXu0 authored Aug 6, 2023
1 parent fbc1ecd commit ab10257
Showing 1 changed file with 16 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,10 @@ class _DesktopSelectionServiceWidgetState
}

currentSelection.value = selection;
editorState.selection = selection;
editorState.updateSelectionWithReason(
selection,
reason: SelectionUpdateReason.uiEvent,
);
}

void _updateSelection() {
Expand Down Expand Up @@ -239,16 +242,18 @@ class _DesktopSelectionServiceWidgetState
clearSelection();
return;
}
if (selectable.cursorStyle == CursorStyle.verticalLine) {
editorState.selection = Selection.collapsed(
selectable.getPositionInOffset(offset),
);
} else {
editorState.selection = Selection(
start: selectable.start(),
end: selectable.end(),
);
}
final selection = selectable.cursorStyle == CursorStyle.verticalLine
? Selection.collapsed(
selectable.getPositionInOffset(offset),
)
: Selection(
start: selectable.start(),
end: selectable.end(),
);
editorState.updateSelectionWithReason(
selection,
reason: SelectionUpdateReason.uiEvent,
);
}

void _onDoubleTapDown(TapDownDetails details) {
Expand Down

0 comments on commit ab10257

Please sign in to comment.