andreycizov / idea-partialnav

Allow PageUp and PageDown to only scroll a partial part of the screen
Apache License 2.0
6 stars 7 forks source link

Crashing since 2022.1 (with workaround for OS X) #12

Open Alexsey opened 2 years ago

Alexsey commented 2 years ago

Just installed the WebStorm 2022.1 EAP. It seems that the old API is not working anymore :(

Stacktrace ``` java.lang.NoSuchMethodError: 'boolean com.intellij.util.SystemProperties.isTrueSmoothScrollingEnabled()' at com.andreycizov.partialnav.PartialPageNavHelper.getVisibleArea(PartialPageNavHelper.java:15) at com.andreycizov.partialnav.PartialPageNavHelper.moveCaretPageUp(PartialPageNavHelper.java:22) at com.andreycizov.partialnav.PartialPageUpAction$Handler.execute(PartialPageUpAction.java:28) at com.intellij.openapi.editor.actionSystem.EditorActionHandler.doExecute(EditorActionHandler.java:161) at com.intellij.openapi.editor.actionSystem.DynamicEditorActionHandler.doExecute(DynamicEditorActionHandler.java:63) at com.intellij.openapi.editor.actionSystem.EditorActionHandler.lambda$execute$2(EditorActionHandler.java:192) at com.intellij.openapi.editor.actionSystem.EditorActionHandler.doIfEnabled(EditorActionHandler.java:89) at com.intellij.openapi.editor.actionSystem.EditorActionHandler.lambda$execute$3(EditorActionHandler.java:191) at com.intellij.openapi.editor.impl.CaretModelImpl.lambda$runForEachCaret$3(CaretModelImpl.java:312) at com.intellij.openapi.editor.impl.CaretModelImpl.doWithCaretMerging(CaretModelImpl.java:421) at com.intellij.openapi.editor.impl.CaretModelImpl.runForEachCaret(CaretModelImpl.java:321) at com.intellij.openapi.editor.impl.CaretModelImpl.runForEachCaret(CaretModelImpl.java:296) at com.intellij.openapi.editor.actionSystem.EditorActionHandler.execute(EditorActionHandler.java:189) at com.intellij.openapi.editor.actionSystem.EditorAction.lambda$actionPerformed$0(EditorAction.java:89) at com.intellij.openapi.command.impl.CoreCommandProcessor.executeCommand(CoreCommandProcessor.java:219) at com.intellij.openapi.command.impl.CoreCommandProcessor.executeCommand(CoreCommandProcessor.java:174) at com.intellij.openapi.editor.actionSystem.EditorAction.actionPerformed(EditorAction.java:98) at com.intellij.openapi.editor.actionSystem.EditorAction.actionPerformed(EditorAction.java:73) at com.intellij.openapi.keymap.impl.ActionProcessor.performAction(ActionProcessor.java:65) at com.intellij.openapi.keymap.impl.IdeKeyEventDispatcher$1.performAction(IdeKeyEventDispatcher.java:576) at com.intellij.openapi.keymap.impl.IdeKeyEventDispatcher.lambda$doPerformActionInner$10(IdeKeyEventDispatcher.java:701) at com.intellij.openapi.application.TransactionGuardImpl.performActivity(TransactionGuardImpl.java:106) at com.intellij.openapi.application.TransactionGuardImpl.performUserActivity(TransactionGuardImpl.java:95) at com.intellij.openapi.keymap.impl.IdeKeyEventDispatcher.lambda$doPerformActionInner$11(IdeKeyEventDispatcher.java:701) at com.intellij.openapi.actionSystem.ex.ActionUtil.performDumbAwareWithCallbacks(ActionUtil.java:265) at com.intellij.openapi.keymap.impl.IdeKeyEventDispatcher.doPerformActionInner(IdeKeyEventDispatcher.java:698) at com.intellij.openapi.keymap.impl.IdeKeyEventDispatcher.processAction(IdeKeyEventDispatcher.java:642) at com.intellij.openapi.keymap.impl.IdeKeyEventDispatcher.processAction(IdeKeyEventDispatcher.java:587) at com.intellij.openapi.keymap.impl.IdeKeyEventDispatcher.processActionOrWaitSecondStroke(IdeKeyEventDispatcher.java:470) at com.intellij.openapi.keymap.impl.IdeKeyEventDispatcher.inInitState(IdeKeyEventDispatcher.java:459) at com.intellij.openapi.keymap.impl.IdeKeyEventDispatcher.dispatchKeyEvent(IdeKeyEventDispatcher.java:227) at com.intellij.ide.IdeEventQueue.dispatchKeyEvent(IdeEventQueue.java:788) at com.intellij.ide.IdeEventQueue._dispatchEvent(IdeEventQueue.java:734) at com.intellij.ide.IdeEventQueue.lambda$dispatchEvent$6(IdeEventQueue.java:433) at com.intellij.openapi.progress.impl.CoreProgressManager.computePrioritized(CoreProgressManager.java:801) at com.intellij.ide.IdeEventQueue.lambda$dispatchEvent$7(IdeEventQueue.java:432) at com.intellij.openapi.application.TransactionGuardImpl.performActivity(TransactionGuardImpl.java:119) at com.intellij.ide.IdeEventQueue.performActivity(IdeEventQueue.java:598) at com.intellij.ide.IdeEventQueue.lambda$dispatchEvent$8(IdeEventQueue.java:430) at com.intellij.openapi.application.impl.ApplicationImpl.runIntendedWriteActionOnCurrentThread(ApplicationImpl.java:873) at com.intellij.ide.IdeEventQueue.dispatchEvent(IdeEventQueue.java:478) at java.desktop/java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:203) at java.desktop/java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:124) at java.desktop/java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:113) at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:109) at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101) at java.desktop/java.awt.EventDispatchThread.run(EventDispatchThread.java:90) ```
Vladivost commented 2 years ago

Hey guys, really enjoyed this plugin prior to 2022.1, will this be fixed or is it not possible with the new API?

Alexsey commented 2 years ago

My Java and IDEA API knowledge are too bad to fix this in a reasonable time :( I do hope that someday @andreycizov would find some time to fix this. Meanwhile, I've written a workaround for OS X with Hammerspoon I can share

To run it just follow instructions from the official Hamerspoon docs on Hello World but use the snippet from below. Please, ask if something wouldn't work

Code ```lua -- the replacement of the unsupported since 2022.1 plugin "Partial Navigation" -- Setup block local ideName = "WebStorm" -- change this to match your IDE name local partialNavigateLines = 10 -- number of lines per PageUp / PageDown local scrollSpeed = 4 -- page scroll speed on press & hold. More is faster local isPartialNavigationActive = true -- move caret by partialNavigateLines local isPartialNavigationWithScrollActive = false -- move caret and scroll by partialNavigateLines local isPartialScrollActive = false -- scroll by partialNavigateLines -- Initialization blocks local keyRepeatDelay = hs.eventtap.keyRepeatDelay() -- https://github.com/Hammerspoon/hammerspoon/issues/1082#issuecomment-281163614 local function repeatKey (times, mods, key) return function () for _ = 1, times do hs.eventtap.keyStroke(mods, key, keyRepeatDelay) end end end local function remapAndRepeatHotkey (map) local fromKey = map.from.key local fromMod = type(map.from.mod) == "string" and {map.from.mod} or map.from.mod or {} local toKey = map.to.key local toMod = type(map.to.mod) == "string" and {map.to.mod} or map.to.mod or {} return hs.hotkey.new( fromMod, fromKey, repeatKey(partialNavigateLines, toMod, toKey), nil, repeatKey(scrollSpeed, toMod, toKey) ) end -- the list of available "key" values https://www.hammerspoon.org/docs/hs.keycodes.html#map -- the list of available "mod" values https://www.hammerspoon.org/docs/hs.hotkey.html#assignable local partialPageUp = remapAndRepeatHotkey({ from = {key = "pageup"}, to = {key = "up"}, }) local partialPageDown = remapAndRepeatHotkey({ from = {key = "pagedown"}, to = {key = "down"}, }) local partialPageUpWithSelection = remapAndRepeatHotkey({ from = {mod = "shift", key = "pageup"}, to = {mod = "shift", key = "up"}, }) local partialPageDownWithSelection = remapAndRepeatHotkey({ from = {mod = "shift", key = "pagedown"}, to = {mod = "shift", key = "down"}, }) local partialPageUpAndScroll = remapAndRepeatHotkey({ from = {mod = "ctrl", key = "pageup"}, to = {mod = "ctrl", key = "up"}, }) local partialPageDownAndScroll = remapAndRepeatHotkey({ from = {mod = "ctrl", key = "pagedown"}, to = {mod = "ctrl", key = "down"}, }) local partialPageUpAndScrollWithSelection = remapAndRepeatHotkey({ from = {mod = {"ctrl", "shift"}, key = "pageup"}, to = {mod = {"ctrl", "shift"}, key = "up"}, }) local partialPageDownAndScrollWithSelection = remapAndRepeatHotkey({ from = {mod = {"ctrl", "shift"}, key = "pagedown"}, to = {mod = {"ctrl", "shift"}, key = "down"}, }) local partialPageUpScroll = remapAndRepeatHotkey({ from = {mod = "alt", key = "pageup"}, to = {mod = "alt", key = "up"}, }) local partialPageDownScroll = remapAndRepeatHotkey({ from = {mod = "alt", key = "pagedown"}, to = {mod = "alt", key = "down"}, }) local function enablePartialNavigation () partialPageUp:enable() partialPageDown:enable() partialPageUpWithSelection:enable() partialPageDownWithSelection:enable() end local function disablePartialNavigation () partialPageUp:disable() partialPageDown:disable() partialPageUpWithSelection:disable() partialPageDownWithSelection:disable() end local function enablePartialNavigationWithScroll () partialPageUpAndScroll:enable() partialPageDownAndScroll:enable() partialPageUpAndScrollWithSelection:enable() partialPageDownAndScrollWithSelection:enable() end local function disablePartialNavigationWithScroll () partialPageUpAndScroll:disable() partialPageDownAndScroll:disable() partialPageUpAndScrollWithSelection:disable() partialPageDownAndScrollWithSelection:disable() end local function enablePartialScroll () partialPageUpScroll:enable() partialPageDownScroll:enable() end local function disablePartialScroll () partialPageUpScroll:disable() partialPageDownScroll:disable() end -- although idePartialNavigator is not used anywhere, -- do NOT delete this variable and do NOT make it local - -- otherwise, Lua would garbage collect the watcher in a minute. -- The main code of this handler will be executed every time the IDE would be focused or unfocused idePartialNavigator = hs.application.watcher.new(function(name, event) -- skip if no window is focused if name == nil then return end -- skip if it's not the IDE window if not string.find(name, ideName) then return end if event == hs.application.watcher.activated then if isPartialNavigationActive == true then enablePartialNavigation() end if isPartialNavigationWithScrollActive == true then enablePartialNavigationWithScroll() end if isPartialScrollActive == true then enablePartialScroll() end elseif event == hs.application.watcher.deactivated then if isPartialNavigationActive == true then disablePartialNavigation() end if isPartialNavigationWithScrollActive == true then disablePartialNavigationWithScroll() end if isPartialScrollActive == true then disablePartialScroll() end end end):start() -- Code below will be executed only once on Hammerspoon (re)start function isIdeFocused () return string.find(hs.window.focusedWindow():application():title(), ideName) end if isIdeFocused() then if isPartialNavigationActive == true then enablePartialNavigation() end if isPartialNavigationWithScrollActive == true then enablePartialNavigationWithScroll() end if isPartialScrollActive == true then enablePartialScroll() end end ```
A few differences with the plugin 1. (Bad) It will work only on Mac (both M-series and x86) 2. (Bad) It can set only PageUp / PageDown to navigate to a specific number of lines and it can **not** navigate by page percentage* 3. (Good) Keymap setup is optional 4. (Good) It will work not only in Editor but across all IDE views e.g. in files tree view 5. (Good) Even more nice features - see Extras section *Because Hammerspoon is operating on the applications level, there is no way to get Editor's current number of lines. Though it's still possible to get the size of a window and adjust the pagination size, the results would be far from expected as soon as you would have a horizontal tab or a horizontal split
Basic setup All the setup is at the top of the script: * set the name of your IDE to `ideName` variable * (optional) set the number of lines you would like PageUp / PageDown to move the caret to `partialNavigateLines` variables * (optional) adjust the speed of the scrolling when PageUp / PageDown is pressed and hold with `scrollSpeed`
Extras Partial navigation with scroll: * go to _Preferences_ -> _Keymap_ and set some hotkey to _"Move Up and Scroll"_, _"Move Down and Scroll"_, _"Move Up and Scroll with Selection"_, and _"Move Down and Scroll with Selection"_ * in the Setup block of the code, set `isPartialNavigationWithScrollActive` to `true` * in the definitions of `partialPageUpAndScroll`, `partialPageDownAndScroll`, `partialPageUpAndScrollWithSelection` and `partialPageDownAndScrollWithSelection` change arguments to match the mapping so `from` would be the value you would like to press and `to` would be the hotkey you've set in _Keymap_ * if you would like to disable the default partial navigation without scroll, in the Setup block of the script set `isPartialNavigationActive` to `false` Partial page scroll: * go to _Preferences_ -> _Keymap_ and set some hotkey to _"Scroll Up"_ and _"Scroll Down"_ * in the Setup block of the code, set `isPartialScrollActive` to `true` * in the definitions of `partialPageUpScroll` and `partialPageDownScroll` change arguments to match the mapping so `from` would be the value you would like to press and `to` would be the hotkey you've set in _Keymap_ [The list of available "key" values](https://www.hammerspoon.org/docs/hs.keycodes.html#map) [The list of available "mod" values](https://www.hammerspoon.org/docs/hs.hotkey.html#assignable)
What does the script do * It remaps PageUp / PageDown / Shift + PageUp / Shift + PageDown to repeated Up / Down / Shift + Up / Shift + Down * The remap would be enable/disable everytime the IDE would be focused/unfocused * Applications other than the IDE would **not** be affected * PageUp / PageDown hotkeys with modifiers other than Shift would **not** be affected (e.g. PageUp + Opt or PageDown + Shift + Ctrl would not be remapped)
Vladivost commented 2 years ago

Hey, thanks a lot for that, tried it, the script does in fact work!

victor-falcon commented 2 years ago

It's there any alternative for this plugin or plan to update it? I roll back from 2022.1 because this 😢

Alexsey commented 2 years ago

@victor-falcon are you using Windows/Linux or did the Hammerspoon workaround didn't work for you?

victor-falcon commented 2 years ago

@Alexsey I just tried it, and it works great. I never heard of Hammerspoon and I love it!

canelhasmateus commented 2 years ago

https://github.com/andreycizov/idea-partialnav/pull/13

momomo commented 2 years ago

I updated the plugin source code to kotlin, changed some code, and is now working on EAP version again.

Attached plugin file. Later possibly with fork.

Unable to upload. Here: https://easyupload.io/fhigl2

Valid for 30 days.

momomo commented 2 years ago

Here is a slighlty updated version with more options:

https://eu5.easyupload.io/download/3dqvrp/5i4g0xtsrf8zdzliad20l7siqknzphe6

image

image

momomo commented 2 years ago

Even more options:

https://easyupload.io/1jcu38

Vladivost commented 2 years ago

Hey everyone, I've found another plugin that does roughly the same thing and works with the latest Intellij versions, maybe someone will find it helpful so I'm sharing it https://plugins.jetbrains.com/plugin/17449-jumper (I'm not affiliated with the creator)

momomo commented 2 years ago

image

momomo commented 2 years ago

Here is the alternative release based on this one instead:

https://github.com/momomo/mmm.intellij.plugin.Partial/tree/master/releases

Just download the zip file and install.

FeralFox commented 1 year ago

Here is the alternative release based on this one instead:

https://github.com/momomo/mmm.intellij.plugin.Partial/tree/master/releases

Just download the zip file and install.

Thank you! Works like a charm. Hope the PR of @canelhasmateus will be approved soon. https://github.com/andreycizov/idea-partialnav/pull/13

momomo commented 1 year ago

Breaks in latest EAP. Need a new release.

momomo commented 1 year ago

Spent another hour to make another build:

si.mmm.intellij.plugin.Partial-1002.42.zip

ryletko commented 1 year ago

for 2022.3 https://github.com/ryletko/mmm.intellij.plugin.Partial/releases/tag/Release

FeralFox commented 7 months ago

I have published a working version of this plugin which can be used as an alternative. It is called Partial Page Scrolling. Basically I didn't want to always download the fixed version and apply it manually in all of the IDE's I work with. It is based on this repo and does also work when the IDE is indexing. I made some adjustments, most important to mention is that the dropdown for relative scrolling height adaption has been replaced with a normal text entry. So the user can define any percentage he/she wants instead of choosing from a predefined list. The plugin is here https://plugins.jetbrains.com/plugin/23332-partial-page-scrolling

@andreycizov I hope this is fine and the contributions are sufficient. If not, please contact me. Thank you very much for your effort when creating this plugin: 🍻

Merry Christmas