Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix RangeError in markdownFormatting and markdownLink Function #388

Merged
merged 1 commit into from
Mar 10, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading