mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IDEA-53596 Soft wrap for editors
Corrected 'Home' key typing processing in order to move to the first non-white space symbol on a line if caret is not positioned at the first column
This commit is contained in:
@@ -26,6 +26,9 @@ import org.jetbrains.annotations.NonNls;
|
||||
* single logical <code>(line; column)</code> pair matches soft wrap-introduced virtual space, i.e. different visual positions
|
||||
* correspond to the same logical position. It's convenient to store exact visual location details within the logical
|
||||
* position in order to relief further {@code 'logical position' -> 'visual position'} mapping.
|
||||
* <p/>
|
||||
* <b>Note:</b> two objects of this class are considered equal if their logical line and column are equal. I.e. all logical positions
|
||||
* for soft wrap-introduced virtual space and the first document symbol after soft wrap are considered to be equal.
|
||||
*
|
||||
* @see Editor#offsetToLogicalPosition(int)
|
||||
* @see Editor#logicalPositionToOffset(LogicalPosition)
|
||||
@@ -134,18 +137,11 @@ public class LogicalPosition implements Comparable<LogicalPosition> {
|
||||
if (!(o instanceof LogicalPosition)) return false;
|
||||
final LogicalPosition logicalPosition = (LogicalPosition) o;
|
||||
|
||||
return column == logicalPosition.column && line == logicalPosition.line && softWrapLines == logicalPosition.softWrapLines
|
||||
&& linesFromActiveSoftWrap == logicalPosition.linesFromActiveSoftWrap
|
||||
&& softWrapColumnDiff == logicalPosition.softWrapColumnDiff && foldedLines == logicalPosition.foldedLines
|
||||
&& foldingColumnDiff == logicalPosition.foldingColumnDiff;
|
||||
return column == logicalPosition.column && line == logicalPosition.line;
|
||||
}
|
||||
|
||||
public int hashCode() {
|
||||
int result = 29 * line + column;
|
||||
result = result * 29 + softWrapLines;
|
||||
result = 29 * result + softWrapColumnDiff;
|
||||
result = 29 * result + foldedLines;
|
||||
return 29 * result + foldingColumnDiff;
|
||||
return 29 * line + column;
|
||||
}
|
||||
|
||||
@NonNls
|
||||
|
||||
+4
-1
@@ -233,10 +233,13 @@ public class EditorActionUtil {
|
||||
}
|
||||
else if (logLineToUse == logCaretLine) {
|
||||
int line = currentVisCaret.line;
|
||||
int column = 0;
|
||||
int column;
|
||||
if (currentVisCaret.column == 0) {
|
||||
column = findSmartIndentColumn(editor, currentVisCaret.line);
|
||||
}
|
||||
else {
|
||||
column = findFirstNonSpaceColumnOnTheLine(editor, currentVisCaret.line);
|
||||
}
|
||||
caretModel.moveToVisualPosition(new VisualPosition(line, column));
|
||||
}
|
||||
else {
|
||||
|
||||
@@ -279,7 +279,7 @@ public class SoftWrapModelImpl implements SoftWrapModelEx {
|
||||
|
||||
@NotNull
|
||||
public LogicalPosition adjustLogicalPosition(@NotNull LogicalPosition defaultLogical, @NotNull VisualPosition visual) {
|
||||
if (myActive > 0 || !isSoftWrappingEnabled() || myWraps.isEmpty()) {
|
||||
if (myActive > 0 || !isSoftWrappingEnabled() || myWraps.isEmpty() || myEditor.getDocument().getTextLength() <= 0) {
|
||||
return defaultLogical;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user