account for widget span automatical matches when getting match by text by offset
This commit is contained in:
parent
5829c3e1ca
commit
b285ffed88
2 changed files with 16 additions and 6 deletions
|
|
@ -437,11 +437,21 @@ class InputBar extends StatelessWidget {
|
|||
return;
|
||||
}
|
||||
|
||||
choreographer.chatController.onSelectMatch(
|
||||
choreographer.igcController.getMatchByOffset(
|
||||
controller!.selection.baseOffset,
|
||||
),
|
||||
);
|
||||
// Normalization matchs are widget spans that mess with offsets,
|
||||
// so we need to adjust the offset accordingly
|
||||
int adjustedOffset = controller!.selection.baseOffset;
|
||||
final normalizationMatches =
|
||||
choreographer.igcController.recentNormalizationMatches;
|
||||
if (normalizationMatches == null || normalizationMatches.isEmpty) return;
|
||||
for (final match in normalizationMatches) {
|
||||
if (match.updatedMatch.match.offset < adjustedOffset &&
|
||||
match.updatedMatch.match.length > 0) {
|
||||
adjustedOffset += (match.updatedMatch.match.length - 1);
|
||||
}
|
||||
}
|
||||
|
||||
final match = choreographer.igcController.getMatchByOffset(adjustedOffset);
|
||||
choreographer.chatController.onSelectMatch(match);
|
||||
}
|
||||
// Pangea#
|
||||
|
||||
|
|
|
|||
|
|
@ -85,7 +85,7 @@ class SpanData {
|
|||
};
|
||||
|
||||
bool isOffsetInMatchSpan(int offset) =>
|
||||
offset >= this.offset && offset < this.offset + length;
|
||||
offset >= this.offset && offset <= this.offset + length;
|
||||
|
||||
SpanChoice? get bestChoice {
|
||||
return choices?.firstWhereOrNull(
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue