Skip to content

Commit

Permalink
Disable highlighting at bigger files to increase loading speed
Browse files Browse the repository at this point in the history
  • Loading branch information
gsantner committed Nov 1, 2019
1 parent e17cf7d commit 18d2f86
Showing 1 changed file with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import net.gsantner.markor.activity.MainActivity;
import net.gsantner.markor.model.Document;
import net.gsantner.markor.util.AppSettings;
import net.gsantner.markor.util.ContextUtils;

import java.io.File;

Expand All @@ -39,6 +40,7 @@ interface OnTextChangedListener {
void onTextChanged(String text);
}

private final boolean _isDeviceGoodHardware;
private boolean _modified = true;
private boolean _hlEnabled = false;
private boolean _isSpellingRedUnderline;
Expand All @@ -64,6 +66,7 @@ public HighlightingEditor(Context context, AttributeSet attrs) {
setHighlightingEnabled(as.isHighlightingEnabled());
}

_isDeviceGoodHardware = new ContextUtils(context).isDeviceGoodHardware();
_isSpellingRedUnderline = !as.isDisableSpellingRedUnderline();
addTextChangedListener(new TextWatcher() {
@Override
Expand Down Expand Up @@ -127,7 +130,7 @@ public void reloadHighlighter() {
}

private void highlightWithoutChange(Editable editable) {
if (_hlEnabled) {
if (_hlEnabled && editable.length() <= (_isDeviceGoodHardware ? 100000 : 35000)) {
_modified = false;
try {
if (MainActivity.IS_DEBUG_ENABLED) {
Expand Down

0 comments on commit 18d2f86

Please sign in to comment.