Skip to content

fix: make PTY width configurable to prevent output truncation#446

Open
timblaktu wants to merge 2 commits intostevearc:masterfrom
timblaktu:fix-pty-width-truncation
Open

fix: make PTY width configurable to prevent output truncation#446
timblaktu wants to merge 2 commits intostevearc:masterfrom
timblaktu:fix-pty-width-truncation

Conversation

@timblaktu
Copy link
Copy Markdown

Problem

When overseer runs tasks with use_terminal=true (the default), it sets a PTY width of vim.o.columns - 4. This causes compiler output and other program output to be truncated when the Neovim window is narrow (~100 columns or less), as programs detect the terminal width and adjust their output accordingly.

This is especially problematic for compiler error messages that get cut off in the quickfix window, making debugging difficult.

Solution

This PR adds a new pty_width option to the jobstart strategy that allows users to configure the PTY width behavior:

  • "auto" (default): Current behavior - uses vim.o.columns - 4
  • <number>: Set a fixed width (e.g., 500) to prevent truncation
  • nil: Don't specify any width constraint, letting the PTY use its default

Usage Examples

Prevent truncation with a fixed width:

require("overseer").setup({
  strategy = { 
    "jobstart",
    {
      use_terminal = true,
      pty_width = 500,  -- Fixed width prevents truncation
    }
  }
})

Disable width specification entirely:

require("overseer").setup({
  strategy = { 
    "jobstart",
    {
      use_terminal = true,
      pty_width = nil,  -- No width constraint
    }
  }
})

Keep current behavior (default):

require("overseer").setup({
  strategy = { 
    "jobstart",
    {
      use_terminal = true,
      pty_width = "auto",  -- Same as vim.o.columns - 4
    }
  }
})

Testing

Tested with narrow Neovim windows (~100 columns) running C++ compilation with long error messages. With pty_width = 500, error messages are no longer truncated in the quickfix window.

Breaking Changes

None - the default behavior remains unchanged. This is a backward-compatible enhancement.

Related Issues

When overseer runs tasks with use_terminal=true (the default), it sets
a PTY width of vim.o.columns - 4. This causes compiler output to be
truncated when the Neovim window is narrow, as programs detect the
terminal width and adjust their output accordingly.

This commit adds a new pty_width option to the jobstart strategy that
allows users to:
- Use the default auto behavior (vim.o.columns - 4)
- Set a fixed width to prevent truncation
- Set to nil to not specify any width constraint

Fixes issue stevearc#202
- Add flake.nix with nixvim-based test environment
- Add reproducer script demonstrating the truncation issue
- Add documentation explaining the issue and how to test the fix
- Includes C++ test file with intentionally long error messages
Copy link
Copy Markdown
Owner

@stevearc stevearc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm fine with making the width configurable, but this could be simplified to a 3 or 4 line change. Also, please remove all the unrelated files before we merge.

Comment on lines +16 to 23
--- pty_width nil|integer|string Width of the PTY when use_terminal is true. Can be a number, "auto" (vim.o.columns - 4), or nil (no width specified)
---@return overseer.Strategy
function JobstartStrategy.new(opts)
opts = vim.tbl_extend("keep", opts or {}, {
preserve_output = false,
use_terminal = true,
pty_width = "auto",
})
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This merge strategy won't work as advertised; if you pass in nil it will be overridden by the tbl_extend to be "auto" instead. Also, passing a nil width doesn't mean "no width constraints", it means we will use the default value of the current window width minus the offset due to line numbers etc.

https://github.com/neovim/neovim/blob/5f22cf5af3425fb0d461bf82220a633bebe10932/src/nvim/eval/funcs.c#L3582

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.

Compiler output truncated when Neovim window is narrow

2 participants