mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
make End key work properly for RTL text case
This commit is contained in:
+8
-3
@@ -568,7 +568,7 @@ public class EditorActionUtil {
|
||||
}
|
||||
VisualPosition currentVisualCaret = editor.getCaretModel().getVisualPosition();
|
||||
VisualPosition visualEndOfLineWithCaret
|
||||
= new VisualPosition(currentVisualCaret.line, EditorUtil.getLastVisualLineColumnNumber(editor, currentVisualCaret.line));
|
||||
= new VisualPosition(currentVisualCaret.line, EditorUtil.getLastVisualLineColumnNumber(editor, currentVisualCaret.line), true);
|
||||
|
||||
// There is a possible case that the caret is already located at the visual end of line and the line is soft wrapped.
|
||||
// We want to move the caret to the end of the next visual line then.
|
||||
@@ -590,7 +590,7 @@ public class EditorActionUtil {
|
||||
line++;
|
||||
column = EditorUtil.getLastVisualLineColumnNumber(editor, line);
|
||||
}
|
||||
visualEndOfLineWithCaret = new VisualPosition(line, column);
|
||||
visualEndOfLineWithCaret = new VisualPosition(line, column, true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -617,7 +617,12 @@ public class EditorActionUtil {
|
||||
caretModel.moveToVisualPosition(visualEndOfLineWithCaret);
|
||||
}
|
||||
else {
|
||||
caretModel.moveToOffset(newOffset);
|
||||
if (editor instanceof EditorImpl && ((EditorImpl)editor).myUseNewRendering) {
|
||||
caretModel.moveToLogicalPosition(editor.offsetToLogicalPosition(newOffset).leanForward(true));
|
||||
}
|
||||
else {
|
||||
caretModel.moveToOffset(newOffset);
|
||||
}
|
||||
}
|
||||
|
||||
EditorModificationUtil.scrollToCaret(editor);
|
||||
|
||||
@@ -386,6 +386,26 @@ public class EditorRtlTest extends AbstractEditorTest {
|
||||
checkSelection(0, 0);
|
||||
}
|
||||
|
||||
public void testHomeEnd() throws Exception {
|
||||
init("rr");
|
||||
myEditor.getCaretModel().moveToOffset(1);
|
||||
home();
|
||||
assertVisualCaretLocation(0, false);
|
||||
end();
|
||||
assertVisualCaretLocation(2, false);
|
||||
}
|
||||
|
||||
public void testHomeEndWithSelection() throws Exception {
|
||||
init("rr");
|
||||
myEditor.getCaretModel().moveToOffset(1);
|
||||
homeWithSelection();
|
||||
assertVisualCaretLocation(0, false);
|
||||
checkSelection(0, 1);
|
||||
endWithSelection();
|
||||
assertVisualCaretLocation(2, false);
|
||||
checkSelection(1, 2);
|
||||
}
|
||||
|
||||
private void init(String text) throws IOException {
|
||||
initText(text.replace(RTL_CHAR_REPRESENTATION, RTL_CHAR));
|
||||
}
|
||||
|
||||
+8
@@ -518,6 +518,14 @@ public abstract class LightPlatformCodeInsightTestCase extends LightPlatformTest
|
||||
executeAction(IdeActions.ACTION_EDITOR_MOVE_LINE_END);
|
||||
}
|
||||
|
||||
protected static void homeWithSelection() {
|
||||
executeAction(IdeActions.ACTION_EDITOR_MOVE_LINE_START_WITH_SELECTION);
|
||||
}
|
||||
|
||||
protected static void endWithSelection() {
|
||||
executeAction(IdeActions.ACTION_EDITOR_MOVE_LINE_END_WITH_SELECTION);
|
||||
}
|
||||
|
||||
protected static void copy() {
|
||||
executeAction(IdeActions.ACTION_EDITOR_COPY);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user