File tree Expand file tree Collapse file tree 5 files changed +60
-1
lines changed
Expand file tree Collapse file tree 5 files changed +60
-1
lines changed Original file line number Diff line number Diff line change @@ -16,6 +16,10 @@ function M.swap_position()
1616 require (' opencode.ui.ui' ).swap_position ()
1717end
1818
19+ function M .toggle_zoom ()
20+ require (' opencode.ui.ui' ).toggle_zoom ()
21+ end
22+
1923function M .open_input ()
2024 core .open ({ new_session = false , focus = ' input' , start_insert = true })
2125end
@@ -898,6 +902,11 @@ M.commands = {
898902 fn = M .toggle_pane ,
899903 },
900904
905+ toggle_zoom = {
906+ desc = ' Toggle window zoom' ,
907+ fn = M .toggle_zoom ,
908+ },
909+
901910 swap = {
902911 desc = ' Swap pane position left/right' ,
903912 fn = M .swap_position ,
Original file line number Diff line number Diff line change @@ -23,6 +23,7 @@ M.defaults = {
2323 [' <leader>oq' ] = { ' close' , desc = ' Close Opencode window' },
2424 [' <leader>os' ] = { ' select_session' , desc = ' Select session' },
2525 [' <leader>op' ] = { ' configure_provider' , desc = ' Configure provider' },
26+ [' <leader>oz' ] = { ' toggle_zoom' , desc = ' Toggle zoom' },
2627 [' <leader>od' ] = { ' diff_open' , desc = ' Open diff view' },
2728 [' <leader>o]' ] = { ' diff_next' , desc = ' Next diff' },
2829 [' <leader>o[' ] = { ' diff_prev' , desc = ' Previous diff' },
@@ -86,6 +87,7 @@ M.defaults = {
8687 position = ' right' ,
8788 input_position = ' bottom' ,
8889 window_width = 0.40 ,
90+ zoom_width = 0.8 ,
8991 input_height = 0.15 ,
9092 picker_width = 100 ,
9193 display_model = true ,
Original file line number Diff line number Diff line change 3535--- @field opencode_server OpencodeServer | nil
3636--- @field api_client OpencodeApiClient
3737--- @field event_manager EventManager | nil
38+ --- @field pre_zoom_width integer | nil
3839--- @field required_version string
3940--- @field opencode_cli_version string | nil
4041--- @field append fun ( key : string , value : any )
@@ -60,6 +61,7 @@ local _state = {
6061 display_route = nil ,
6162 current_mode = nil ,
6263 last_output = 0 ,
64+ pre_zoom_width = nil ,
6365 -- context
6466 last_sent_context = nil ,
6567 current_context_config = {},
Original file line number Diff line number Diff line change 1- local M = {}
21local config = require (' opencode.config' )
32local state = require (' opencode.state' )
43local renderer = require (' opencode.ui.renderer' )
@@ -7,6 +6,8 @@ local input_window = require('opencode.ui.input_window')
76local footer = require (' opencode.ui.footer' )
87local topbar = require (' opencode.ui.topbar' )
98
9+ local M = {}
10+
1011--- @param windows OpencodeWindowState ?
1112function M .close_windows (windows )
1213 if not windows then
@@ -244,4 +245,24 @@ function M.swap_position()
244245 end )
245246end
246247
248+ function M .toggle_zoom ()
249+ local windows = state .windows
250+ if not windows or not state .windows .output_win or not state .windows .input_win then
251+ return
252+ end
253+
254+ local width
255+
256+ if state .pre_zoom_width then
257+ width = state .pre_zoom_width
258+ state .pre_zoom_width = nil
259+ else
260+ state .pre_zoom_width = vim .api .nvim_win_get_width (windows .output_win )
261+ width = math.floor (config .ui .zoom_width * vim .o .columns )
262+ end
263+
264+ vim .api .nvim_win_set_config (windows .input_win , { width = width })
265+ vim .api .nvim_win_set_config (windows .output_win , { width = width })
266+ end
267+
247268return M
Original file line number Diff line number Diff line change @@ -518,4 +518,29 @@ describe('opencode.api', function()
518518 state .current_model = original_model
519519 end )
520520 end )
521+
522+ describe (' toggle_zoom' , function ()
523+ it (' calls ui.toggle_zoom when toggle_zoom is called' , function ()
524+ stub (ui , ' toggle_zoom' )
525+
526+ api .toggle_zoom ()
527+
528+ assert .stub (ui .toggle_zoom ).was_called ()
529+ end )
530+
531+ it (' is available in the commands table' , function ()
532+ local cmd = api .commands [' toggle_zoom' ]
533+ assert .truthy (cmd , ' toggle_zoom command should exist' )
534+ assert .equal (' Toggle window zoom' , cmd .desc )
535+ assert .is_function (cmd .fn )
536+ end )
537+
538+ it (' routes through command interface' , function ()
539+ stub (ui , ' toggle_zoom' )
540+
541+ api .commands .toggle_zoom .fn ({})
542+
543+ assert .stub (ui .toggle_zoom ).was_called ()
544+ end )
545+ end )
521546end )
You can’t perform that action at this time.
0 commit comments