-
Notifications
You must be signed in to change notification settings - Fork 7
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
Crashing since 2022.1 (with workaround for OS X) #12
Comments
Hey guys, really enjoyed this plugin prior to 2022.1, will this be fixed or is it not possible with the new API? |
My Java and IDEA API knowledge are too bad to fix this in a reasonable time :( 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-- 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
*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 setupAll the setup is at the top of the script:
ExtrasPartial navigation with scroll:
Partial page scroll:
The list of available "key" values What does the script do
|
Hey, thanks a lot for that, tried it, the script does in fact work! |
It's there any alternative for this plugin or plan to update it? I roll back from 2022.1 because this 😢 |
@victor-falcon are you using Windows/Linux or did the Hammerspoon workaround didn't work for you? |
@Alexsey I just tried it, and it works great. I never heard of Hammerspoon and I love it! |
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. |
Here is a slighlty updated version with more options: https://eu5.easyupload.io/download/3dqvrp/5i4g0xtsrf8zdzliad20l7siqknzphe6 |
Even more options: |
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) |
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. #13 |
Breaks in latest EAP. Need a new release. |
Spent another hour to make another build: |
I have published a working version of this plugin which can be used as an alternative. It is called @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 |
Just installed the WebStorm 2022.1 EAP. It seems that the old API is not working anymore :(
Stacktrace
The text was updated successfully, but these errors were encountered: