6.6.2 - Alpha2 - 修复代码编辑器跳转行尾错位
This commit is contained in:
@@ -3,6 +3,7 @@ package org.autojs.autojs.ui.edit;
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.Context;
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
import android.view.ContextThemeWrapper;
|
||||
import android.view.View;
|
||||
import android.widget.EditText;
|
||||
@@ -41,7 +42,7 @@ public class ClassSearchDialogBuilder extends MaterialDialog.Builder {
|
||||
|
||||
public ClassSearchDialogBuilder(@NonNull Context context) {
|
||||
super(new ContextThemeWrapper(context, R.style.AppTheme));
|
||||
mHandler = new Handler();
|
||||
mHandler = new Handler(Looper.getMainLooper());
|
||||
initViews(getContext());
|
||||
AndroidClassIndices.getInstance(getContext());
|
||||
}
|
||||
|
||||
@@ -250,20 +250,27 @@ class CodeEditor : HVScrollView {
|
||||
val layout = codeEditText.layout
|
||||
val line = LayoutHelper.getLineOfChar(layout, minOf(codeEditText.selectionStart, codeEditText.selectionEnd))
|
||||
if (line >= 0 && line < layout.lineCount) {
|
||||
codeEditText.setSelection(layout.getLineEnd(line))
|
||||
// codeEditText.setSelection(layout.getLineEnd(line) - 1)
|
||||
val lineEnd = layout.getLineEnd(line)
|
||||
val text = codeEditText.text.toString()
|
||||
val finalPosition = when {
|
||||
lineEnd > 0 && text[lineEnd - 1] == '\n' -> {
|
||||
lineEnd - 1
|
||||
}
|
||||
else -> lineEnd
|
||||
}
|
||||
codeEditText.setSelection(finalPosition)
|
||||
}
|
||||
}
|
||||
|
||||
fun setTheme(theme: Theme?) {
|
||||
fun setTheme(theme: Theme) {
|
||||
mTheme = theme
|
||||
setBackgroundColor(mTheme!!.backgroundColor)
|
||||
setBackgroundColor(theme.backgroundColor)
|
||||
mJavaScriptHighlighter.setTheme(theme)
|
||||
val text = codeEditText.text
|
||||
if (text != null) {
|
||||
mJavaScriptHighlighter.updateTokens(text.toString())
|
||||
}
|
||||
codeEditText.setTheme(mTheme!!)
|
||||
codeEditText.setTheme(theme)
|
||||
invalidate()
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user