-
Notifications
You must be signed in to change notification settings - Fork 766
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
Caret position and view scrolling fixes #280
Conversation
Note that this doesn't actually work, as we ignore <Tab> in insert mode, so that other actions, specifically the live template action, can handle it. Without this, Emmet doesn't work (VIM-674). The scrolling does work with <C-I>
For the |
That's a nice update, you're a scrolling master. |
I'm hoping scrolling is mostly done now 😁 (apart from those way too large JavaDocs. Still not sure how to handle those…) I don't think tab behaviour is too bad either way right now, and that comment was really as a thinking-out-loud, note-to-self kind of comment. I don't think it desperately needs a fix, but at some point it might be worth taking a look at how we handle some of those special keys to see if we can get even better handling. |
Kind of, yes. Given an inlay that is related to preceding text, insert mode will now place the caret before the inlay. So in this case, the caret should appear after the However, this particular example isn't of an inlay related to preceding text, although it looks like it is, and indeed should be. I raised an issue with the Kotlin plugin (KTIJ-3768) but it turns out to be a bug in the platform. The API that the Kotlin plugin was using was failing to set the "related to preceding text" properly for all Kotlin hints like this. I've fixed it in the platform, but sadly only for 212. You can see the actual change in action better with inline rename. This adds an inlay hint to the end of the text of the symbol to be renamed and this is correctly set to "relates to preceding text". The insert mode caret stays between the caret and the inlay hint. The normal mode caret only shows over text. Screen.Recording.2021-04-23.at.12.24.02.am.mov |
Aha, I see! I've just tried it on 212 and it works like that. I know why I haven't noticed this before, as I understand you place the caret before the inlay only in case of insert mode. But I usually navigate to the end of the word using |
|
To follow up on this, there are several things happening: Firstly, in 211 and earlier, there is a bug in the platform that always makes Kotlin inlay hints apply to following text, instead of applying some to preceding text, like this type hint. Secondly, the current code actually positions the caret incorrectly, because at the time it's positioned, the current mode hasn't yet been changed, and we calculate inlay handling for the wrong mode/caret shape. Thirdly, in 211 and earlier IntelliJ would reinitialise editor settings whenever the caret changed between bar and block shape. This did a lot of unnecessary extra work (see IDEA-262153), including repositioning the caret to the current offset, in case e.g. tab size has changed. This will also recalculate visual positioning with regard to inlay hints, and ironically, repositions the caret to the original desired location. 212 has updated the handling of the bar/block caret switch handling to do less work, and no longer resets the caret location, so no longer "fixes" the incorrect location for IdeaVim's handling. I've got a fix locally as part of a refactoring of caret handling. I hope to have a PR soon. |
Fixes an issue where the caret was incorrectly positioned because it was moved before the mode was changed. This wasn't visible in 211 because a couple of bugs in the platform combined to put the caret in the right place. See JetBrains#280, IDEA-262153 and KTIJ-3768
A bunch of minor fixes to caret positioning and view scrolling. It looks like a big PR, but half of it is tests :)
sidescroll
andsidescrolloff
options. Moving up/down and typing enter will scroll vertically correctly, also followingscrolloff
andscrolljump
. Tab in insert mode does not scroll correctly. See below.sidescrolloff
when moving the viewG
to place the last line at the bottom of the filescrolloff
lines of the bottom of a file, with virtual space (VIM-2177)<C-F>
/<C-B>
and<C-E>
/<C-Y>
Note that
<Tab>
doesn't scroll the view correctly when in insert mode (although the<C-I>
synonym does). This is a limitation of the way we handle conflicting shortcut keys. This key is handled by IdeaVim first and has a special case to ignoreVK_TAB
in insert mode. This means the other IDE actions get a chance to handle<Tab>
, notably the live templates action, and means Emmet will work in insert mode (VIM-674, f6cb04c7). The downside is that if the live templates action doesn't have anything to expand, IdeaVim doesn't get another chance to handle it.