UNPKG

sussudio

Version:

An unofficial VS Code Internal API

26 lines (25 loc) 1.23 kB
/*--------------------------------------------------------------------------------------------- * Copyright (c) Microsoft Corporation. All rights reserved. * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ import { getZoomLevel, setZoomFactor, setZoomLevel } from "../../../base/browser/browser.mjs"; import { webFrame } from "../../../base/parts/sandbox/electron-sandbox/globals.mjs"; import { zoomLevelToZoomFactor } from "../common/window.mjs"; /** * Apply a zoom level to the window. Also sets it in our in-memory * browser helper so that it can be accessed in non-electron layers. */ export function applyZoom(zoomLevel) { webFrame.setZoomLevel(zoomLevel); setZoomFactor(zoomLevelToZoomFactor(zoomLevel)); // Cannot be trusted because the webFrame might take some time // until it really applies the new zoom level // See https://github.com/microsoft/vscode/issues/26151 setZoomLevel(zoomLevel, false /* isTrusted */); } export function zoomIn() { applyZoom(getZoomLevel() + 1); } export function zoomOut() { applyZoom(getZoomLevel() - 1); }