Skip to content

feat: remove winfixbuf and make ctrl w o work in opencode window - #479

Closed
jugarpeupv wants to merge 3 commits into
sudo-tee:mainfrom
jugarpeupv:feature/upstream-main
Closed

feat: remove winfixbuf and make ctrl w o work in opencode window#479
jugarpeupv wants to merge 3 commits into
sudo-tee:mainfrom
jugarpeupv:feature/upstream-main

Conversation

@jugarpeupv

@jugarpeupv jugarpeupv commented Jul 26, 2026

Copy link
Copy Markdown
Contributor

Remove winfixbuf from output/input windows so that file pickers (telescope, snacks, fyler) and :e can switch the buffer without E1513 errors. Extend the BufEnter teardown guard to all positions.

When the buffer is replaced externally, keep the output window open with the new file buffer instead of closing it, so the file remains visible after opencode UI tears down.

Summary

When winfixbuf=true was set on opencode output/input windows (split and float positions), any attempt to switch the buffer via file pickers (telescope, snacks, fyler) or :e would throw E1513: Cannot switch buffer. 'winfixbuf' is enabled — a hard error with no graceful recovery.

Solution

Three coordinated changes:

  1. Remove winfixbuf=true from output and input windows — lets external tools switch the buffer without E1513.
  2. Extend BufEnter teardown guard to all positions — was previously conditional on position == 'current'. Now detects when a non-opencode buffer enters an opencode window and tears down the UI cleanly.
  3. Keep the output window open when the buffer was replaced externallyclose_or_restore_output_window now checks if the buffer already changed before closing the window. If it was replaced by fyler/telescope/etc., the window stays open with the new file buffer visible.

Files changed

File Change
lua/opencode/ui/output_window.lua Removed winfixbuf=true for non-current positions
lua/opencode/ui/input_window.lua Removed winfixbuf=true for non-current positions
lua/opencode/ui/autocmds.lua Made BufEnter teardown guard apply to all positions (was current-only)
lua/opencode/ui/ui.lua close_or_restore_output_window: detect buffer replacement, keep window open

Behaviour

Scenario Before After
:e file in opencode window E1513 error Opens file, opencode UI tears down cleanly
Telescope/snacks pick file from opencode window E1513 error Opens file in window, opencode UI tears down
Fyler open file targeting opencode window E1513 error Opens file in window, keeps window open, tears down rest
Normal opencode toggle off Window closes (unchanged) Window closes (unchanged)

Remove winfixbuf from output/input windows so that file pickers
(telescope, snacks, fyler) and :e can switch the buffer without
E1513 errors. Extend the BufEnter teardown guard to all positions.

When the buffer is replaced externally, keep the output window
open with the new file buffer instead of closing it, so the file
remains visible after opencode UI tears down.
Only teardown opencode UI when the output window itself closes,
not when input/footer closes. Add <C-w>o mapping to both output
and input buffers using buffer-ID comparison to avoid nil-table
issues in the window-ID approach.
@jugarpeupv jugarpeupv changed the title Feature/upstream main feat: remove winfixbuf and make ctrl w o work in opencode window Jul 26, 2026
@jugarpeupv

Copy link
Copy Markdown
Contributor Author

The inline_input restores multiline initial_text and places the cursor at its end test failed on macos-latest, v0.11.4 — it's a pre-existing flaky test unrelated to these changes. The vim.wait(50, ...) at  tests/unit/inline_input_spec.lua:147 times out when cursor position doesn't settle within 50ms on macOS CI. Bumped the timeout to 100ms to make it more resilient.

Increase vim.wait timeout from 50ms to 100ms for the multiline
initial_text cursor position assertion, which is prone to timing
out on macos-latest with Neovim 0.11.4.
@jugarpeupv

Copy link
Copy Markdown
Contributor Author

This does not work well either X.X

@jugarpeupv jugarpeupv closed this Jul 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant