Skip to content

Commit 849b575

Browse files
Merge remote-tracking branch 'upstream/main'
2 parents caf3386 + 45b1f83 commit 849b575

File tree

3 files changed

+24
-4
lines changed

3 files changed

+24
-4
lines changed

editor/src/main/java/io/github/rosemoe/sora/graphics/TextRow.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -978,6 +978,17 @@ private float handleSingleTextElement(RowElement e, ListPointers pointers,
978978
}
979979
ctx.maxOffset = 0f;
980980
}
981+
if (ctx.targetHorizontalOffset != -1f) {
982+
float runOffset = ctx.targetHorizontalOffset - offset - localOffset;
983+
if (isRtl) {
984+
runOffset = tabWidth - runOffset;
985+
}
986+
if (runOffset > tabWidth / 2f) {
987+
ctx.resultCharOffset = index + 1;
988+
} else {
989+
ctx.resultCharOffset = index;
990+
}
991+
}
981992
if (ctx.regionBuffer != null && index >= ctx.startCharOffset && index < ctx.endCharOffset) {
982993
ctx.regionBuffer.commitRegion(offset + localOffset, offset + localOffset + tabWidth);
983994
}

editor/src/main/java/io/github/rosemoe/sora/widget/CodeEditor.java

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1769,14 +1769,14 @@ public void indentLines(boolean onlyIfSelected) {
17691769
final var requiredSpaces = tabWidth - (spaces % tabWidth);
17701770
if (spaceCount > 0 && tabCount > 0) {
17711771
// indentation contains spaces as well as tabs
1772-
// replace the leading indentation with appropriate indendation (according to language.useTabs())
1772+
// replace the leading indentation with appropriate indentation (according to language.useTabs())
17731773
// this should be done while incrementing the indentation
17741774
final var finalSpaceCount = ((requiredSpaces == 0 ? tabWidth : requiredSpaces) + spaces) / tabWidth;
17751775
text.replace(i, 0, i, endColumn, StringsKt.repeat(tabString, finalSpaceCount));
17761776
continue;
17771777
}
17781778

1779-
if (requiredSpaces == 0) {
1779+
if (requiredSpaces == tabWidth) {
17801780
// line is evenly indented
17811781
// increase the indentation by \t or tabWidthSpaces
17821782
text.insert(i, endColumn, tabString);
@@ -1818,7 +1818,7 @@ public void unindentSelection() {
18181818
final var extraSpaces = spaces % tabWidth;
18191819
if (spaceCount > 0 && tabCount > 0) {
18201820
// indentation contains spaces as well as tabs
1821-
// replace the leading indentation with appropriate indendation (according to language.useTabs())
1821+
// replace the leading indentation with appropriate indentation (according to language.useTabs())
18221822
// this should be done while decrementing the indentation
18231823
final var finalSpaceCount = Math.abs(spaces - (extraSpaces == 0 ? tabWidth : extraSpaces)) / tabWidth;
18241824
text.replace(i, 0, i, endColumn, StringsKt.repeat(tabString, finalSpaceCount));
@@ -1846,6 +1846,10 @@ public void unindentSelection() {
18461846
*/
18471847
protected void commitTab() {
18481848
if (inputConnection != null && isEditable()) {
1849+
if (inputConnection.composingText.isComposing()) {
1850+
// This external change will damage the composing text (#784)
1851+
restartInput();
1852+
}
18491853
inputConnection.commitTextInternal(createTabString(), true);
18501854
}
18511855
}
@@ -1913,6 +1917,11 @@ public float updateCursorAnchor() {
19131917
matrix.postTranslate(b[0], b[1]);
19141918
builder.setMatrix(matrix);
19151919
builder.setSelectionRange(cursor.getLeft(), cursor.getRight());
1920+
1921+
var composingText = inputConnection.composingText;
1922+
if (composingText.isComposing()) {
1923+
builder.setComposingText(composingText.startIndex, text.substring(composingText.startIndex, composingText.endIndex));
1924+
}
19161925
builder.setInsertionMarkerLocation(x, getRowTop(l) - getOffsetY(), getRowBaseline(l) - getOffsetY(), getRowBottom(l) - getOffsetY(), visible ? CursorAnchorInfo.FLAG_HAS_VISIBLE_REGION : CursorAnchorInfo.FLAG_HAS_INVISIBLE_REGION);
19171926
inputMethodManager.updateCursorAnchorInfo(this, builder.build());
19181927
}

gradle/libs.versions.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ junit = { module = "junit:junit", version = "4.13.2" }
2626
gson = { module = "com.google.code.gson:gson", version = "2.13.2" }
2727
jcodings = { module = "org.jruby.jcodings:jcodings", version = "1.0.63" }
2828
joni = { module = "org.jruby.joni:joni", version = "2.2.6" }
29-
snakeyaml-engine = { module = "org.snakeyaml:snakeyaml-engine", version = "2.10" }
29+
snakeyaml-engine = { module = "org.snakeyaml:snakeyaml-engine", version = "3.0.1" }
3030
moshi = { module = "com.squareup.moshi:moshi", version = "1.15.2" }
3131
jdt-annotation = { module = "org.eclipse.jdt:org.eclipse.jdt.annotation", version = "2.4.100" }
3232
monarch-code = { module = "io.github.dingyi222666.monarch:monarch", version = "1.0.3" }

0 commit comments

Comments
 (0)