-
Notifications
You must be signed in to change notification settings - Fork 283
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
Add keybindings for zoom in, zoom out and zoom reset #1629
Add keybindings for zoom in, zoom out and zoom reset #1629
Conversation
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.
Awesome @ArtemDrozdov. I haven't tried it out yet, just looked over the code, but it seems sound to me! I have a few suggestions and a reorganization request below though.
src/Store/VimStoreConnector.re
Outdated
let zoomStep = 0.2; | ||
let defaultZoom = 1.0; | ||
let minZoomValue = 0.0; | ||
let maxZoomValue = 2.8; |
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.
Could you put these in a Constants
sub-module at the top of the file?
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.
Yes, of course.
src/Store/VimStoreConnector.re
Outdated
let calculatedZoomValue = | ||
switch (zoomAction) { | ||
| ZoomIn => currentZoomValue +. zoomStep | ||
| ZoomOut => currentZoomValue -. zoomStep | ||
| ZoomReset => defaultZoom | ||
}; |
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.
What's the reason you pass in a zoomAction
instead of just passing in the value directly?
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.
What do you mean by
instead of just passing in the value directly
Can't get your point.
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.
Looking closer, I guess you can't pass in currentZoomValue +. zoomStep)
directly instead of ZoomIn
because you need currentZoomValue
. But you could do zoomEffect(state, zoom => zoom +. zoomStep)
.
src/Store/VimStoreConnector.re
Outdated
let newZoomValue = | ||
calculatedZoomValue < minZoomValue | ||
? minZoomValue | ||
: calculatedZoomValue > maxZoomValue | ||
? maxZoomValue : calculatedZoomValue; |
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.
You can use Utility.IntEx.clamp
for this. It would be significantly more readable I think.
src/Store/VimStoreConnector.re
Outdated
| Command("workbench.action.zoomIn") => ( | ||
state, | ||
zoomEffect(state, ZoomIn), | ||
) | ||
| Command("workbench.action.zoomOut") => ( | ||
state, | ||
zoomEffect(state, ZoomOut), | ||
) | ||
| Command("workbench.action.zoomReset") => ( | ||
state, | ||
zoomEffect(state, ZoomReset), | ||
) |
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.
I don't see any reason for these and the effect to need to live in VimStoreConnector
. Could you move it to CommandStoreConnector
instead (unless there's a reason I don't see)?
94321c4
to
c95e67b
Compare
Pushed changes according @glennsl comments:
|
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.
Looks and works great. Thanks @ArtemDrozdov!
Oh, CI fails on an unused variable warning. That should be a quick fix though. |
Added keybindings for zoom in, zoom out and zoom reset according #1423 issue.
I checked zooming behavior in VSCode and they have next logic: default value is 0, minimum is -8 and maximum is 9. Zooming step is 1 which equals to 20%.
Short summary what was done in this PR:
Minimum value for zooming is 0 because on lower values there is no changes in UI.
And probably there should be some logic to process Cmd + = on Mac and Ctrl + = on Linux/Windows for example. Because with current implementation both of those combinations are working on Mac.
Would love to hear any comments and suggestion!