-
Notifications
You must be signed in to change notification settings - Fork 767
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Introduce ScrollGroup #583
Introduce ScrollGroup #583
Conversation
This file is licensed under the Vim license, so that scrolling the caret into view can be based on the Vim implementation
@@ -145,10 +145,10 @@ class IjVimCaret(val caret: Caret) : VimCaretBase() { | |||
override fun hashCode(): Int = this.caret.hashCode() | |||
} | |||
|
|||
val VimCaret.ij: Caret | |||
inline val VimCaret.ij: Caret |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just curious, any advantages from making this field inlined?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Possibly not :) I didn't measure anything, but it felt like an overhead to call a function that simply does a cast and property access, especially when we've got that same pattern repeated in the code. It just means there's no difference to putting the pattern in the calling code or using this helper function, which is a lot nicer.
I've always wondered if it's worth putting IjVimEditor
into Editor
s user data, to prevent allocating too frequently, too.
Awesome as always. Thank you! |
This PR extracts the scrolling functionality from
MotionGroup
andVimMotionGroup
and introduces theVimScrollGroup
interface and theScrollGroup
service. The methods onVimMotionGroup
were checked for external usages before moving. The code has also been converted into Kotlin.Furthermore, the
scrollCaretIntoView
functions in theScrollViewHelper.kt
file are now licensed under the Vim license. These functions control how the window is scrolled to place the caret at least'scrolloff'
lines away from the top/bottom of the window, or place the caret to the middle of the window. The current implementation is based on reading Vim source, but is a different implementation that does not support soft wrapped lines. Scrolling is a complex area in Vim, and to accurately mimic Vim's behaviour with soft wraps, this implementation will need to be rewritten to match Vim's implementation.PS. I migrated
MotionGroup
to Kotlin too, because who doesn't like a bit of Kotlin?