Skip to content

Commit

Permalink
Fixing markdown insert bug for launch
Browse files Browse the repository at this point in the history
  • Loading branch information
BijoySingh committed Feb 11, 2018
1 parent 72ad6e8 commit 1ea80c8
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ android {
applicationId "com.bijoysingh.quicknote"
minSdkVersion 17
targetSdkVersion 27
versionCode 56
versionName "4.4.0"
versionCode 57
versionName "4.4.1"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
javaCompileOptions {
annotationProcessorOptions {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import android.os.Bundle
import android.support.v4.content.ContextCompat
import android.text.Editable
import android.text.InputType
import android.text.Selection
import android.text.TextWatcher
import android.util.TypedValue
import android.view.View
Expand All @@ -19,7 +18,7 @@ import com.bijoysingh.quicknote.activities.sheets.TextSizeBottomSheet
import com.bijoysingh.quicknote.activities.sheets.TextSizeBottomSheet.Companion.KEY_TEXT_SIZE
import com.bijoysingh.quicknote.activities.sheets.TextSizeBottomSheet.Companion.TEXT_SIZE_DEFAULT
import com.bijoysingh.quicknote.formats.Format
import com.bijoysingh.quicknote.formats.FormatType.*
import com.bijoysingh.quicknote.formats.FormatType.CODE
import com.bijoysingh.quicknote.formats.MarkdownType
import com.bijoysingh.quicknote.utils.ThemeColorType
import com.bijoysingh.quicknote.utils.ThemeManager
Expand Down Expand Up @@ -147,8 +146,12 @@ open class FormatTextViewHolder(context: Context, view: View) : RecyclerViewHold

edit.setText(stringBuilder.toString())

val additionTokenLength = (if (markdownType.requiresNewLine) 1 else 0) + markdownType.startToken.length
edit.setSelection(startString.length + additionTokenLength)
try {
val additionTokenLength = (if (markdownType.requiresNewLine) 1 else 0) + markdownType.startToken.length
edit.setSelection(Math.min(startString.length + additionTokenLength, edit.text.length))
} catch (_: Exception) {
// Ignore the exception
}
}

companion object {
Expand Down

0 comments on commit 1ea80c8

Please sign in to comment.