Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

resize-window doesn't apply given increment accurately #6498

Open
xeyownt opened this issue Jul 25, 2023 · 1 comment
Open

resize-window doesn't apply given increment accurately #6498

xeyownt opened this issue Jul 25, 2023 · 1 comment
Labels

Comments

@xeyownt
Copy link

xeyownt commented Jul 25, 2023

Describe the bug
I'm using remote-control and resize-window to build a tab layout with window of given size (using layout splits).
When applying the resize-window the new window sizes are not the one expected.

To Reproduce
Steps to reproduce the behavior:

  1. Run the following script in a kitty --config NONE -o allow_remote_control=yes window:
#! /bin/bash

function do-resize() 
{
  INCREMENT=$1
  L1=$(kitty @ ls | jq '.[].tabs[].windows[] | select( .title == "left" ) | .columns')
  R1=$(kitty @ ls | jq '.[].tabs[].windows[] | select( .title == "right" ) | .columns')
  kitty @ resize-window --match title:left --increment $INCREMENT --axis horizontal
  L2=$(kitty @ ls | jq '.[].tabs[].windows[] | select( .title == "left" ) | .columns')
  R2=$(kitty @ ls | jq '.[].tabs[].windows[] | select( .title == "right" ) | .columns')
  echo "Left: $L1 -> $L2 [$((L2 - L1))] Right: $R1 -> $R2 [$((R2 - R1))]"
}
kitty @ launch --type tab --title "left" --tab-title "first" > /dev/null
kitty @ goto-layout --match title:first splits
kitty @ launch --match title:first --location vsplit --title "right" --keep-focus > /dev/null
do-resize 2
do-resize 2
do-resize 2
do-resize 2
do-resize 2
  1. This gives the output below. We see that we sometimes get a wrong increment, and sometimes the increment on the left and right window is different.
Left: 106 -> 108 [2] Right: 106 -> 104 [-2]
Left: 108 -> 110 [2] Right: 104 -> 102 [-2]
Left: 110 -> 113 [3] Right: 102 -> 100 [-2]
Left: 113 -> 115 [2] Right: 100 -> 97 [-3]
Left: 115 -> 117 [2] Right: 97 -> 95 [-2]
  1. Using an increment of 10, we get the following output, where the increment is always wrong. In fact the bigger the increment the bigger the difference.
Left: 106 -> 117 [11] Right: 106 -> 95 [-11]
Left: 117 -> 128 [11] Right: 95 -> 84 [-11]
Left: 128 -> 139 [11] Right: 84 -> 73 [-11]
Left: 139 -> 151 [12] Right: 73 -> 62 [-11]
Left: 151 -> 162 [11] Right: 62 -> 51 [-11]
  1. The same applies for hsplit and --axis vertical.

Environment details

kitty 0.29.1 (a0341af3f8) created by Kovid Goyal
Linux zavcxl0007 6.1.0-6-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.15-1 (2023-03-05) x86_64
Debian GNU/Linux bookworm/sid zavcxl0007 /dev/tty

Running under: X11
Frozen: True
Paths:
  kitty: /home/peetersm/.local/kitty.app/bin/kitty
  base dir: /home/peetersm/.local/kitty.app/lib/kitty
  extensions dir: /home/peetersm/.local/kitty.app/lib/kitty-extensions
  system shell: /bin/bash
Loaded config overrides:
  allow_remote_control yes

Config options different from defaults:
allow_remote_control yes

Important environment variables seen by the kitty process:
	PATH                                /home/peetersm/bin/local:/home/peetersm/bin:/home/peetersm/.local/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games:/home/peetersm/.fzf/bin
	LANG                                en_US.UTF-8
	EDITOR                              vim
	SHELL                               /bin/bash
	DISPLAY                             :0
	USER                                peetersm
	XDG_MENU_PREFIX                     gnome-
	LC_MONETARY                         en_DK.UTF-8
	XDG_SESSION_DESKTOP                 gnome-xorg
	XDG_SESSION_TYPE                    x11
	LC_PAPER                            en_DK.UTF-8
	XDG_CURRENT_DESKTOP                 GNOME
	XDG_SESSION_CLASS                   user
	LC_MEASUREMENT                      en_DK.UTF-8
	XDG_RUNTIME_DIR                     /run/user/1000
	LC_TIME                             en_DK.UTF-8
	XDG_DATA_DIRS                       /usr/share/gnome:/usr/local/share/:/usr/share/
	LC_NUMERIC                          en_DK.UTF-8
@xeyownt xeyownt added the bug label Jul 25, 2023
@kovidgoyal
Copy link
Owner

windows sizes in kitty are based on biases not cell sizes so when you resize in cells you will get a bias that comes close to the asked for size but there is no guarantee it will be exact. That said I am sure the bias calculations could be improved for better consistency, patches are welcome, relevant code is in the layout folder.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants