mirror of
https://gitee.com/zhangsken/AndroidIDE.git
synced 2026-10-16 07:49:44 +08:00
fix(editor): tab in symbol input does not shift snippet to next tab stop
This commit is contained in:
@@ -17,6 +17,7 @@
|
||||
*/
|
||||
package com.itsaky.androidide.adapters;
|
||||
|
||||
import static com.itsaky.androidide.preferences.utils.EditorUtilKt.getIndentationString;
|
||||
import static com.itsaky.androidide.utils.ResourceUtilsKt.resolveAttr;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
@@ -95,6 +96,18 @@ public class SymbolInputAdapter extends RecyclerView.Adapter<SymbolInputAdapter.
|
||||
if (selectionOffset < 0 || selectionOffset > text.length()) {
|
||||
return;
|
||||
}
|
||||
|
||||
final var controller = editor.getSnippetController();
|
||||
if ("\t".equals(text) && controller.isInSnippet()) {
|
||||
controller.shiftToNextTabStop();
|
||||
return;
|
||||
}
|
||||
|
||||
if ("\t".equals(text)) {
|
||||
text = getIndentationString();
|
||||
selectionOffset = text.length();
|
||||
}
|
||||
|
||||
var cur = editor.getText().getCursor();
|
||||
if (cur.isSelected()) {
|
||||
editor
|
||||
|
||||
@@ -17,9 +17,6 @@
|
||||
*/
|
||||
package com.itsaky.androidide.utils
|
||||
|
||||
import com.itsaky.androidide.preferences.internal.tabSize
|
||||
import com.itsaky.androidide.preferences.internal.useSoftTab
|
||||
import com.itsaky.androidide.preferences.utils.indentationString
|
||||
import com.itsaky.androidide.ui.SymbolInputView.Symbol
|
||||
import java.io.File
|
||||
|
||||
@@ -124,17 +121,12 @@ object Symbols {
|
||||
}
|
||||
|
||||
private class TabSymbol : Symbol("↹") {
|
||||
|
||||
override fun getCommit(): String {
|
||||
return createTabChars()
|
||||
return "\t"
|
||||
}
|
||||
|
||||
override fun getOffset(): Int {
|
||||
return createTabChars().length
|
||||
}
|
||||
|
||||
private fun createTabChars(): String {
|
||||
return indentationString
|
||||
return 1
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+2
-1
@@ -27,6 +27,7 @@ import com.itsaky.androidide.lsp.java.utils.EditHelper
|
||||
import com.itsaky.androidide.lsp.models.CompletionItem
|
||||
import com.itsaky.androidide.lsp.models.CompletionResult
|
||||
import com.itsaky.androidide.lsp.models.MatchLevel
|
||||
import com.itsaky.androidide.preferences.internal.tabSize
|
||||
import java.nio.file.Path
|
||||
import openjdk.source.tree.ClassTree
|
||||
import openjdk.source.tree.CompilationUnitTree
|
||||
@@ -88,7 +89,7 @@ class SnippetCompletionProvider(
|
||||
JavaSnippetRepository.snippets[JavaSnippetScope.GLOBAL]?.let { addAll(it) }
|
||||
}
|
||||
|
||||
val indent = EditHelper.indent(task.task, task.root(), path.leaf)
|
||||
val indent = EditHelper.indent(task.task, task.root(), path.leaf) - tabSize
|
||||
for (snippet in snippets) {
|
||||
val matchLevel = matchLevel(snippet.prefix, partial)
|
||||
if (matchLevel == MatchLevel.NO_MATCH) {
|
||||
|
||||
Reference in New Issue
Block a user