Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
小 白蛋
Intellij Community
Commits
7e48f773
Commit
7e48f773
authored
10 years ago
by
Dmitry Batrak
Browse files
Options
Download
Email Patches
Plain Diff
IDEA-132554 undesirable editor scrolling on reformat
parent
ea5c1ba3
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
platform/platform-impl/src/com/intellij/openapi/editor/impl/EditorImpl.java
+19
-5
...impl/src/com/intellij/openapi/editor/impl/EditorImpl.java
with
19 additions
and
5 deletions
+19
-5
platform/platform-impl/src/com/intellij/openapi/editor/impl/EditorImpl.java
+
19
-
5
View file @
7e48f773
...
...
@@ -1701,15 +1701,17 @@ public final class EditorImpl extends UserDataHolderBase implements EditorEx, Hi
}
private
void
bulkUpdateStarted
()
{
myFoldingModel
.
onBulkDocumentUpdateStarted
();
saveCaretRelativePosition
();
myCaretModel
.
onBulkDocumentUpdateStarted
();
mySoftWrapModel
.
onBulkDocumentUpdateStarted
();
myFoldingModel
.
onBulkDocumentUpdateStarted
();
}
private
void
bulkUpdateFinished
()
{
myFoldingModel
.
onBulkDocumentUpdateFinished
();
myCaretModel
.
onBulkDocumentUpdateFinished
();
mySoftWrapModel
.
onBulkDocumentUpdateFinished
();
myCaretModel
.
onBulkDocumentUpdateFinished
();
clearTextWidthCache
();
...
...
@@ -1722,6 +1724,8 @@ public final class EditorImpl extends UserDataHolderBase implements EditorEx, Hi
updateGutterSize
();
repaintToScreenBottom
(
0
);
updateCaretCursor
();
restoreCaretRelativePosition
();
}
private
void
beforeChangedUpdate
(
@NotNull
DocumentEvent
e
)
{
...
...
@@ -1733,9 +1737,7 @@ public final class EditorImpl extends UserDataHolderBase implements EditorEx, Hi
return
;
}
Rectangle
visibleArea
=
getScrollingModel
().
getVisibleArea
();
Point
pos
=
visualPositionToXY
(
getCaretModel
().
getVisualPosition
());
myCaretUpdateVShift
=
pos
.
y
-
visibleArea
.
y
;
saveCaretRelativePosition
();
// We assume that size container is already notified with the visual line widths during soft wraps processing
if
(!
mySoftWrapModel
.
isSoftWrappingEnabled
())
{
...
...
@@ -1779,9 +1781,21 @@ public final class EditorImpl extends UserDataHolderBase implements EditorEx, Hi
repaintLines
(
startLine
,
endLine
);
}
restoreCaretRelativePosition
();
}
private
void
saveCaretRelativePosition
()
{
Rectangle
visibleArea
=
getScrollingModel
().
getVisibleArea
();
Point
pos
=
visualPositionToXY
(
getCaretModel
().
getVisualPosition
());
myCaretUpdateVShift
=
pos
.
y
-
visibleArea
.
y
;
}
private
void
restoreCaretRelativePosition
()
{
Point
caretLocation
=
visualPositionToXY
(
getCaretModel
().
getVisualPosition
());
int
scrollOffset
=
caretLocation
.
y
-
myCaretUpdateVShift
;
getScrollingModel
().
disableAnimation
();
getScrollingModel
().
scrollVertically
(
scrollOffset
);
getScrollingModel
().
enableAnimation
();
}
public
boolean
hasTabs
()
{
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment