microsoft / vscode

Visual Studio Code
https://code.visualstudio.com
MIT License
160.61k stars 28.14k forks source link

Allow configuration of zoom step percentage for fine-grained control of zoom #214775

Open mydoghasfleas opened 1 month ago

mydoghasfleas commented 1 month ago

The difference in zoom between zoom level 0 and zoom level 1 is quite large. I would like something in-between.

Currently, you can zoom in and out at a fixed percentage step which, according to the settings, is 20% (i.e. the zoom changes by 20% in or out).

image

I would like to make the zoom step percentage configurable, so that I can zoom, e.g. 5% or 10% at a go when using the shortcuts (Ctrl+Shift+ minus or plus).

VSCodeTriageBot commented 1 month ago

This feature request is now a candidate for our backlog. The community has 60 days to upvote the issue. If it receives 20 upvotes we will move it to our backlog. If not, we will close it. To learn more about how we handle feature requests, please see our documentation.

Happy Coding!

mrienstra commented 4 days ago

You can manually obtain a precise level of zoom by modifying "window.zoomLevel". "window.zoomLevel": 0, is the default value, and "window.zoomLevel": 1, corresponding to one level of default zoom. So a setting of "window.zoomLevel": 0.5, will get you a half-step of zoom. But I agree with you, allowing users to modify the default step size would be really nice.

I've found 3 extensions that somewhat offer this functionality.

  Installs Rating   PRs Last commit Issues Version Released Updated Installs, sort
Zoom Bar 96K 4.5 https://github.com/wraith13/zoombar-vscode 3 a year ago 10 1.4.4 8/26/2018 2/17/2023 96000
Custom Window Zoom 13.2K 4.6 https://github.com/cbengtson85/custom-window-zoom 0 5 years ago 1 1.1.4 3/10/2018 3/12/2018 13200
Zoomer 2.9K 5 https://github.com/anthonyattard/zoomer 0 2 months ago 0 0.3.1 4/5/2022 5/20/2024 2900

Zoom Bar:

Custom Window Zoom:

Zoomer:

If you want to play with all three, in settings.json:

  "customWindowZoom.zoomLevelChangeValue": 0.25,
  "window.zoomLevel": 0,
  "zoombar.zoomUnit": 5,
  "zoomer.zoomIncrement": 0.25,

Keep settings.json open, and you can watch "window.zoomLevel" change as you zoom in and out.

sebastianvitterso commented 21 hours ago

It's great that there are extensions for this, but this is an issue that vscode itself should offer the solution to.

Looking into relevant code, the change would be minor:

  1. Add a parameter to settings (something like "window.zoomIncrement"), defaulting to 1 (current behaviour).
  2. Update ZoomInAction and ZoomOutAction as follows:
// src/vs/workbench/electron-sandbox/actions/windowActions.ts#L117

export class ZoomInAction extends BaseZoomAction {
    ...
    override run(accessor: ServicesAccessor): Promise<void> {
-       return super.setZoomLevel(accessor, getZoomLevel(getActiveWindow()) + 1);
+       return super.setZoomLevel(accessor, getZoomLevel(getActiveWindow()) + getZoomIncrement());
    }
}

export class ZoomOutAction extends BaseZoomAction {
    override run(accessor: ServicesAccessor): Promise<void> {
-       return super.setZoomLevel(accessor, getZoomLevel(getActiveWindow()) - 1);
+       return super.setZoomLevel(accessor, getZoomLevel(getActiveWindow()) - getZoomIncrement());
    }

Seems like it should be a quick fix for anyone who has done any work on vscode before, might even be a good #good-first-issue.