@@ -23,6 +23,7 @@ import {
2323} from '$lib/file-explorer/quick-look/quick-look-state.svelte'
2424import { invoke } from '@tauri-apps/api/core'
2525import { addToast } from '$lib/ui/toast'
26+ import { getEffectiveShortcuts } from '$lib/shortcuts'
2627import { getSetting , setSetting } from '$lib/settings'
2728import { openSettingsWindow } from '$lib/settings/settings-window'
2829import { openErrorReportDialog } from '$lib/error-reporter/error-report-flow.svelte'
@@ -91,6 +92,31 @@ function handleTextRegionShortcut(commandId: string): boolean {
9192 return true
9293}
9394
95+ /**
96+ * Shows a transient toast confirming a zoom change. Surfaces the reset shortcut
97+ * (or menu path if no shortcut is bound) so users who hit ⌘+/⌘- by accident
98+ * know how to get back to 100%.
99+ */
100+ function showZoomToast ( oldSize : number , newSize : number ) : void {
101+ if ( oldSize === newSize ) return
102+
103+ const resetShortcut = getEffectiveShortcuts ( 'view.zoom.set100' ) [ 0 ]
104+ const resetHint = resetShortcut
105+ ? `You can reset the zoom level to 100% by ${ resetShortcut } .`
106+ : 'You can reset the zoom level to 100% at View > Zoom > 100%.'
107+
108+ let message : string
109+ if ( newSize === 100 ) {
110+ message = 'Zoom reset to 100%.'
111+ } else if ( newSize > oldSize ) {
112+ message = `Zoom increased to ${ newSize } %. ${ resetHint } `
113+ } else {
114+ message = `Zoom decreased to ${ newSize } %. ${ resetHint } `
115+ }
116+
117+ addToast ( message , { level : 'info' , id : 'zoom-change' } )
118+ }
119+
94120// eslint-disable-next-line complexity -- Command dispatcher handles many cases; switch is the clearest pattern
95121export async function handleCommandExecute ( commandId : string , ctx : CommandDispatchContext ) : Promise < void > {
96122 const explorerRef = ctx . getExplorer ( )
@@ -175,25 +201,32 @@ export async function handleCommandExecute(commandId: string, ctx: CommandDispat
175201 // Each writes `appearance.textSize`; the settings store cross-window-syncs
176202 // and `lib/text-size.svelte.ts` recomputes the effective scale.
177203 case 'view.zoom.set75' :
178- setSetting ( 'appearance.textSize' , 75 )
179- return
180204 case 'view.zoom.set100' :
181- setSetting ( 'appearance.textSize' , 100 )
182- return
183205 case 'view.zoom.set125' :
184- setSetting ( 'appearance.textSize' , 125 )
185- return
186- case 'view.zoom.set150' :
187- setSetting ( 'appearance.textSize' , 150 )
206+ case 'view.zoom.set150' : {
207+ const preset = {
208+ 'view.zoom.set75' : 75 ,
209+ 'view.zoom.set100' : 100 ,
210+ 'view.zoom.set125' : 125 ,
211+ 'view.zoom.set150' : 150 ,
212+ } [ commandId ]
213+ const current = getSetting ( 'appearance.textSize' )
214+ setSetting ( 'appearance.textSize' , preset )
215+ showZoomToast ( current , preset )
188216 return
217+ }
189218 case 'view.zoom.in' : {
190219 const current = getSetting ( 'appearance.textSize' )
191- setSetting ( 'appearance.textSize' , Math . min ( 150 , current + 10 ) )
220+ const next = Math . min ( 150 , current + 10 )
221+ setSetting ( 'appearance.textSize' , next )
222+ showZoomToast ( current , next )
192223 return
193224 }
194225 case 'view.zoom.out' : {
195226 const current = getSetting ( 'appearance.textSize' )
196- setSetting ( 'appearance.textSize' , Math . max ( 75 , current - 10 ) )
227+ const next = Math . max ( 75 , current - 10 )
228+ setSetting ( 'appearance.textSize' , next )
229+ showZoomToast ( current , next )
197230 return
198231 }
199232
0 commit comments