Skip to content

Commit

Permalink
Update markdown_text_input.dart
Browse files Browse the repository at this point in the history
  • Loading branch information
nosmirck committed Sep 22, 2023
1 parent 122f130 commit 583c002
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions lib/markdown_text_input.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import 'dart:io';
import 'dart:math';
import 'dart:ui';

import 'package:expandable/expandable.dart';
Expand Down Expand Up @@ -75,8 +76,8 @@ class _MarkdownTextInputState extends State<MarkdownTextInput> {
final basePosition = textSelection.baseOffset;
var noTextSelected = (textSelection.baseOffset - textSelection.extentOffset) == 0;

var fromIndex = textSelection.baseOffset;
var toIndex = textSelection.extentOffset;
var fromIndex = min(textSelection.baseOffset, textSelection.extentOffset);
var toIndex = max(textSelection.extentOffset, textSelection.baseOffset);

final result = FormatMarkdown.convertToMarkdown(type, _controller.text, fromIndex, toIndex,
titleSize: titleSize, link: link, selectedText: selectedText ?? _controller.text.substring(fromIndex, toIndex));
Expand Down

0 comments on commit 583c002

Please sign in to comment.