mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
fix rtl context determination
This commit is contained in:
@@ -4591,7 +4591,7 @@ public final class EditorImpl extends UserDataHolderBase implements EditorEx, Hi
|
||||
private void setCursorPosition() {
|
||||
final List<CaretRectangle> caretPoints = new ArrayList<CaretRectangle>();
|
||||
for (Caret caret : getCaretModel().getAllCarets()) {
|
||||
boolean isRtl = myUseNewRendering && myView.isRtlLocation(caret.getOffset());
|
||||
boolean isRtl = myUseNewRendering && myView.isRtlLocation(caret.getOffset(), caret.getLogicalPosition().leansForward);
|
||||
VisualPosition caretPosition = caret.getVisualPosition();
|
||||
Point pos1 = visualPositionToXY(caretPosition);
|
||||
Point pos2 = visualPositionToXY(new VisualPosition(caretPosition.line, Math.max(0, caretPosition.column + (isRtl ? -1 : 1))));
|
||||
|
||||
@@ -260,11 +260,12 @@ public class EditorView implements Disposable {
|
||||
myTextLayoutCache.resetToDocumentSize();
|
||||
}
|
||||
|
||||
public boolean isRtlLocation(int offset) {
|
||||
public boolean isRtlLocation(int offset, boolean leanForward) {
|
||||
assertIsDispatchThread();
|
||||
if (myDocument.getTextLength() == 0) return false;
|
||||
int line = myDocument.getLineNumber(offset);
|
||||
LineLayout layout = getLineLayout(line);
|
||||
return layout.isRtlLocation(offset - myDocument.getLineStartOffset(line));
|
||||
return layout.isRtlLocation(offset - myDocument.getLineStartOffset(line), leanForward);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
@@ -204,9 +204,10 @@ class LineLayout {
|
||||
return myBidiRunsInLogicalOrder.length == 0 || myBidiRunsInLogicalOrder.length == 1 && !myBidiRunsInLogicalOrder[0].isRtl();
|
||||
}
|
||||
|
||||
boolean isRtlLocation(int offset) {
|
||||
boolean isRtlLocation(int offset, boolean leanForward) {
|
||||
if (offset == 0 && !leanForward) return false;
|
||||
for (BidiRun run : myBidiRunsInLogicalOrder) {
|
||||
if (offset < run.endOffset) return run.isRtl();
|
||||
if (offset < run.endOffset || offset == run.endOffset && !leanForward) return run.isRtl();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user