Skip to content

Commit

Permalink
Fix RangeError in markdownFormatting and markdownLink Function for Te…
Browse files Browse the repository at this point in the history
…xt Insertion (#388)
  • Loading branch information
Dante291 committed Mar 10, 2024
1 parent b25af79 commit 4817d8c
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion lib/src/pages/home/report_bug.dart
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,13 @@ class _ReportFormState extends ConsumerState<ReportForm> {
int end = _descriptionController.selection.extentOffset;
String text = _descriptionController.text;

if (start < 0) {
start = text.length;
}
if (end < 0 || end < start) {
end = start;
}

if (end < start) {
int temp = start;
start = end;
Expand All @@ -124,6 +131,13 @@ class _ReportFormState extends ConsumerState<ReportForm> {
int end = _descriptionController.selection.extentOffset;
String text = _descriptionController.text;

if (start < 0) {
start = text.length;
}
if (end < 0 || end < start) {
end = start;
}

if (end < start) {
int temp = start;
start = end;
Expand All @@ -137,7 +151,7 @@ class _ReportFormState extends ConsumerState<ReportForm> {
text.substring(end);
_descriptionController.text = text;
_descriptionController.selection =
TextSelection(baseOffset: start + 1, extentOffset: end + 1);
TextSelection(baseOffset: end + 3, extentOffset: end + 3);
}

void markdownNewLine(String newLineText) {
Expand Down

0 comments on commit 4817d8c

Please sign in to comment.