kovidgoyal / kitty

Cross-platform, fast, feature-rich, GPU based terminal
https://sw.kovidgoyal.net/kitty/
GNU General Public License v3.0
24.11k stars 972 forks source link

sometimes text on new line doesn't appear aligned on the far left #5190

Closed refractalize closed 2 years ago

refractalize commented 2 years ago

Describe the bug

Sometimes when using a shell, newlines will start on a new row (correctly) but at the same column as the cursor was previously, not at the far left. Video below will explain this better.

To Reproduce

I realise these instructions aren't ideal, but it's the only way I could reproduce it

  1. Create an app on heroku
  2. login with the command-line tools
  3. Install fzf
  4. Run heroku config -a $MY_APP_NAME | fzf
  5. Try to ctrl-c out of fzf before the config is output
  6. Most of the time the terminal will get itself into a state where the newlines don't start at the far left.

There's definitely some interaction between fzf and heroku here that I wasn't able to reproduce otherwise (I tried replacing heroku config with a script that had similar timing and output, but no.)

Once in this state, any text that has a newline will not reset the column back to 0, or, in other words, the new line will start at the same column as the previous line ended.

Resizing the window (either by resizing the OS window or the window via keyboard shortcut) will reset the line back to the far left again - you can see this in the video.

Screenshots

https://user-images.githubusercontent.com/123917/173082967-a46f3204-1037-4101-9f8d-ae963e524f35.mov

Environment details

kitty 0.25.0 created by Kovid Goyal
Darwin Tims-MacBook-Pro.local 21.4.0 Darwin Kernel Version 21.4.0: Fri Mar 18 00:46:32 PDT 2022; root:xnu-8020.101.4~15/RELEASE_ARM64_T6000 arm64
ProductName:    macOS ProductVersion:   12.3.1 BuildVersion:    21E258
Frozen: True
Paths:
  kitty: /Applications/kitty.app/Contents/MacOS/kitty
  base dir: /Applications/kitty.app/Contents/Resources/kitty
  extensions dir: /Applications/kitty.app/Contents/Resources/Python/lib/kitty-extensions
  system shell: /bin/zsh
Loaded config files:
  /Users/tim/.config/kitty/kitty.conf

Config options different from defaults:
allow_remote_control            y
bold_font                       JetBrainsMono NF Extra Bold
bold_italic_font                JetBrainsMono NF Extra Bold Italic
clipboard_control               ('write-clipboard', 'write-primary')
confirm_os_window_close         1
enabled_layouts                 ['tall', 'stack']
env:
{'LANG': 'en_GB.UTF-8',
 'LC_ALL': 'en_GB.UTF-8',
 'PATH': '/opt/homebrew/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin'}
exe_search_path:
{'/usr/local/bin /opt/homebrew/bin': '/usr/local/bin /opt/homebrew/bin'}
font_family                     JetBrainsMono NF
font_size                       13.0
inactive_text_alpha             0.5
italic_font                     JetBrainsMono NF Italic
listen_on                       unix:/tmp/kitty
macos_option_as_alt             2
scrollback_fill_enlarged_window True
scrollback_pager                ['less', '--ignore-case', '--chop-long-lines', '--RAW-CONTROL-CHARS', '+INPUT_LINE_NUMBER']
scrollback_pager_history_size   4294967295
select_by_word_characters       -_
shell_integration               frozenset({'no-cursor', 'no-title', 'no-rc'})
tab_bar_style                   powerline
tab_title_template              {'➊➋➌➍➎➏➐➑➒'[index-1]} {title}
url_prefixes                    ('http', 'https', 'file', 'ftp')
window_padding_width            FloatEdges(left=10.0, top=10.0, right=10.0, bottom=10.0)
Added mouse actions:
    cmd+left release ungrabbed → mouse_handle_click link
    cmd+left release grabbed → mouse_handle_click link
    cmd+left triplepress ungrabbed → mouse_selection line_from_point
Changed mouse actions:
    left click ungrabbed → mouse_handle_click selection prompt
Added shortcuts:
    shift+3 → send_text all \x23
    opt+3 → send_text all \xa3
    cmd+; → nth_window -1
    cmd+_ → change_font_size current -1.0
    cmd+f → show_last_command_output
    cmd+h → combine : goto_layout tall : neighboring_window left
    cmd+j → combine : goto_layout tall : neighboring_window down
    cmd+l → combine : goto_layout tall : neighboring_window right
    cmd+o → launch --type=background --cwd=current nvrtab --window-id @active-kitty-window-id @selection
    cmd+p → first_window
    shift+cmd+; → goto_tab -1
    shift+cmd+f → launch --cwd=current --stdin-source=@last_cmd_output --type=overlay nvim -R -
    shift+cmd+h → resize_window narrower
    shift+cmd+j > 1 → launch --cwd=current --stdin-source=@screen_scrollback --stdin-add-formatting --type=overlay less +G -R
    shift+cmd+j > 2 → launch --cwd=current --stdin-source=@last_cmd_output --stdin-add-formatting --type=overlay less +G -R
    shift+cmd+j > 3 → launch --cwd=current --stdin-source=@first_cmd_output_on_screen --stdin-add-formatting --type=overlay less +G -R
    shift+cmd+j > 4 → launch --cwd=current --stdin-source=@last_visited_cmd_output --stdin-add-formatting --type=overlay less +G -R
    shift+cmd+j > 5 → launch --cwd=current --stdin-source=@screen --stdin-add-formatting --type=overlay less +G -R
    shift+cmd+k → resize_window taller
    shift+cmd+l → resize_window wider
    shift+cmd+r → load_config_file
    shift+cmd+t → select_tab
    opt+cmd+i → launch --type=overlay show-window-info @active-kitty-window-id
    ctrl+cmd+- → set_background_opacity -0.05
    ctrl+cmd+= → set_background_opacity +0.05
    ctrl+cmd+j → scroll_to_prompt 1
    ctrl+cmd+k → scroll_to_prompt -1
    ctrl+cmd+t → detach_window ask
    ctrl+shift+cmd+f → launch --cwd=current --stdin-source=@screen_scrollback --type=overlay kitty-hyperlinks INPUT_LINE_NUMBER
    ctrl+shift+cmd+h → move_window left
    ctrl+shift+cmd+j → move_window down
    ctrl+shift+cmd+k → move_window up
    ctrl+shift+cmd+l → move_window right
Changed shortcuts:
    ctrl+shift+a > l → set_background_opacity -0.05
    ctrl+shift+a > m → set_background_opacity +0.05
    ctrl+shift+e → kitten hints
    ctrl+shift+k → kitty_shell window
    ctrl+shift+p > n → kitten hints --type linenum nvrtab {path}:{line}
    cmd++ → change_font_size current +1.0
    cmd+- → change_font_size current -1.0
    cmd+0 → change_font_size current 0
    cmd+1 → goto_tab 1
    cmd+2 → goto_tab 2
    cmd+3 → goto_tab 3
    cmd+4 → goto_tab 4
    cmd+5 → goto_tab 5
    cmd+6 → goto_tab 6
    cmd+7 → goto_tab 7
    cmd+8 → goto_tab 8
    cmd+9 → goto_tab 9
    cmd+= → change_font_size current +1.0
    cmd+c → kitten send_to_vim.py copy alt+y
    cmd+k → combine : goto_layout tall : neighboring_window up
    cmd+n → combine : goto_layout tall : launch --cwd=current --copy-colors
    cmd+r → layout_action rotate
    cmd+t → launch --type=tab --location=last
    cmd+v → kitten send_to_vim.py paste alt+p
    cmd+enter → toggle_layout stack
    shift+cmd+w → close_window
Colors:
    active_border_color             #f09483   
    active_tab_background           #29d398   
    active_tab_foreground           #16444d   
    background                      #1c1e26   
    color0                          #131419   
    color1                          #e95678   
    color10                         #3fdaa4   
    color11                         #fbc3a7   
    color12                         #3fc6de   
    color13                         #f075b7   
    color14                         #6be6e6   
    color15                         #feffff   
    color2                          #29d398   
    color3                          #fab795   
    color4                          #26bbd9   
    color5                          #ee64ae   
    color6                          #59e3e3   
    color7                          #c7c7c7   
    color8                          #676767   
    color9                          #ec6a88   
    foreground                      #bababa   
    inactive_border_color           #4d2f29   
    inactive_tab_background         #16444d   
    inactive_tab_foreground         #29d398   

Important environment variables seen by the kitty process:
    PATH                                /Applications/kitty.app/Contents/MacOS:/usr/bin:/bin:/usr/sbin:/sbin
    LANG                                en_US.UTF-8
    SHELL                               /bin/zsh
    USER                                tim

Additional context

I can reproduce this even with kitty --config NONE.

refractalize commented 2 years ago

Update: I was actually able to reproduce this in Terminal.app (macOS) so this is definitely NOT a kitty bug. Can reproduce in zsh as well as bash, seemingly on any terminal. Clearly something wrong with heroku or fzf, but odd that it puts the shell/terminal into a broken state well after these commands have been run. Closing...

refractalize commented 2 years ago

FWIW, i can fix this by comparing stty output with a working terminal and undoing the differences with (in this case) with stty isig iexten icrnl ixon brkint opost or stty sane iutf8