Skip to content

Unable to set size of terminal for job with PTY #11476

Open
@cdelledonne

Description

@cdelledonne

Steps to reproduce

  1. For debugging purposes, create a C file called winsize.c, it will be used to get the size of the terminal. Then compile the above C file, e.g. gcc winsize.c -o winsize.out
    #include <stdio.h>
    #include <unistd.h>
    #include <sys/ioctl.h>
    int main() {
        struct winsize size;
        int err = ioctl(STDOUT_FILENO, TIOCGWINSZ, &size);
        printf("Error: %d, Columns: %d, Rows: %d\n", err, size.ws_col, size.ws_row);
        return 0;
    }
  2. Launch Vim, run a job with PTY and width of 80 columns. The job uses winsize.out to obtain the PTY's size
    let g:out = []
    let opts = {'pty': 1, 'env': {'TERM': getenv('TERM'), 'COLUMNS': 80}, 'out_cb': {c, m -> add(g:out, m)}}
    let job = job_start(['./winsize.out'], opts)
    while ch_status(job) !=# 'closed' | execute 'sleep 5m' | endwhile
    echomsg g:out
  3. Observe the output. In my case, this is
    ['Error: 0, Columns: 0, Rows: 0']
    

Expected behaviour

I would expect the COLUMNS environment variable to set the job PTY's width, as suggested in :help terminal-unix. When I run ./winsize.out in a :terminal, I get something like

Error: 0, Columns: 238, Rows: 27

Version of Vim

9.0.720

Environment

  • Operating system: Fedora Linux, kernel 5.19.16-200
  • Terminal: Tmux
  • Value of $TERM: tmux-256color
  • Shell: ZSH

Logs and stack traces

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions