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

Screen redraw on macOS when using (Neo)vim #4102

Closed
omar25h opened this issue Aug 6, 2023 · 17 comments
Closed

Screen redraw on macOS when using (Neo)vim #4102

omar25h opened this issue Aug 6, 2023 · 17 comments
Labels
bug Something isn't working fixed-in-nightly This is (or is assumed to be) fixed in the nightly builds. multiplexer

Comments

@omar25h
Copy link

omar25h commented Aug 6, 2023

What Operating System(s) are you seeing this problem on?

macOS

Which Wayland compositor or X11 Window manager(s) are you using?

yabai

WezTerm version

20230806-091840-2a7167a0

Did you try the latest nightly build to see if the issue is better (or worse!) than your current version?

Yes, and I updated the version box above to show the version of the nightly that I tried

Describe the bug

It seems that there is an issue with the redrawing of the screen whenever scrolling in neovim.

Wezterm.neovim.redraw.mov

To Reproduce

  • In a pane, open vim or neovim with a file that has at least half the number of lines shown on the screen

  • Split the windows horizontally with :sp

  • In the upper window, go to the top line in the buffer and start scrolling down. Notice how the screen is redrawn in the bottom window.

  • Note: Hitting CTRL+L refreshes the full screen and the bottom window is redrawn as expected

wezterm-recording-REMpIT.cast.txt

Configuration

local wezterm = require 'wezterm'
local act = wezterm.action

local function font_with_fallback(name, params)
  local names = { name, 'Noto Color Emoji', 'JetBrains Mono' }
  return wezterm.font_with_fallback(names, params)
end

local function get_appearance()
  if wezterm.gui then return wezterm.gui.get_appearance() end
  return 'Dark'
end

local function scheme_for_appearance(appearance)
  if appearance:find 'Dark' then return 'GruvboxDark' end
  return 'Gruvbox (Gogh)'
end

local function colors_for_appearance(appearance)
  if appearance == nil then return {} end
  if appearance:find 'Dark' then
    return {
      foreground = '#ebdbb2',
      background = '#282828',

      cursor_bg = '#bdae93',
      cursor_fg = '#665c54',

      selection_fg = '#ebdbb2',
      selection_bg = '#d65d0e',

      scrollbar_thumb = '#222222',

      split = '#444444',

      ansi = {
        '#3c3836',
        '#cc241d',
        '#98971a',
        '#d79921',
        '#458588',
        '#b16286',
        '#689d6a',
        '#a89984',
      },
      brights = {
        '#928374',
        '#fb4934',
        '#b8bb26',
        '#fabd2f',
        '#83a598',
        '#d3869b',
        '#8ec07c',
        '#fbf1c7',
      },

      indexed = { [136] = '#af8700' },
      compose_cursor = 'orange',
    }
  else
    return {}
  end
end

wezterm.on('update-status', function(window, pane)
  local leader = ''
  if window:leader_is_active() then leader = '(L)  ' end

  window:set_right_status(wezterm.format {
    { Text = leader .. window:active_workspace() .. '    ' },
  })
end)

wezterm.on(
  'window-config-reloaded',
  function(window, pane) window:toast_notification('wezterm', 'Configuration reloaded!', nil, 4000) end
)

local function tab_title(tab_info)
  local title = tab_info.tab_title
  local zoom = ''
  if tab_info.active_pane.is_zoomed then zoom = ' (Z)' end

  if title and #title > 0 then return title .. zoom end
  return tab_info.active_pane.title .. zoom
end

wezterm.on('format-tab-title', function(tab, tabs, panes, config, hover, max_width)
  local title = tab_title(tab)

  if tab.is_active then return {
    { Background = { Color = 'Black' } },
    { Text = ' ' .. title .. ' ' },
  } end
  return title
end)

local config = {}
if wezterm.config_builder then config = wezterm.config_builder() end

config.term = 'wezterm'
config.adjust_window_size_when_changing_font_size = false
config.font = font_with_fallback('Maple Mono', { weight = 'Regular' })
config.font_size = 17.0
config.line_height = 1.45
config.font_rules = {
  { italic = true, font = font_with_fallback('Maple Mono', { weight = 'Regular', style = 'Italic' }) },
  {
    italic = true,
    intensity = 'Bold',
    font = font_with_fallback('Maple Mono', { weight = 'Bold', style = 'Italic' }),
  },
  { intensity = 'Bold', font = font_with_fallback('Maple Mono', { weight = 'Bold', style = 'Normal' }) },
}

config.use_resize_increments = false
config.use_fancy_tab_bar = true
config.hide_tab_bar_if_only_one_tab = false
config.window_decorations = 'INTEGRATED_BUTTONS | RESIZE| MACOS_FORCE_DISABLE_SHADOW'
config.allow_square_glyphs_to_overflow_width = 'Always'
config.command_palette_font_size = 16.0
config.front_end = 'WebGpu'
config.webgpu_power_preference = 'HighPerformance'
config.default_cursor_style = 'SteadyBlock'

config.window_frame = {
  font = wezterm.font { family = 'Roboto', weight = 'Bold' },
  font_size = 14.0,
  active_titlebar_bg = '#333333',
  inactive_titlebar_bg = '#333333',
}

config.color_scheme = scheme_for_appearance(get_appearance())
config.colors = colors_for_appearance(get_appearance())

config.leader = { key = '/', mods = 'SUPER', timeout_milliseconds = 2000 }

config.keys = {
  { key = 'UpArrow', mods = 'SUPER', action = act.ActivatePaneDirection 'Up' },
  { key = 'DownArrow', mods = 'SUPER', action = act.ActivatePaneDirection 'Down' },
  { key = 'LeftArrow', mods = 'SUPER', action = act.ActivatePaneDirection 'Left' },
  { key = 'RightArrow', mods = 'SUPER', action = act.ActivatePaneDirection 'Right' },
  { key = 'p', mods = 'SUPER', action = act.ActivateCommandPalette },
  { key = 'z', mods = 'LEADER', action = act.TogglePaneZoomState },
  { key = 'e', mods = 'LEADER|CTRL', action = act.PaneSelect },
  { key = '%', mods = 'LEADER|SHIFT', action = act.SplitHorizontal { domain = 'CurrentPaneDomain' } },
  { key = '"', mods = 'LEADER|SHIFT', action = act.SplitVertical { domain = 'CurrentPaneDomain' } },
  { key = '/', mods = 'LEADER|SUPER', action = act.ActivateLastTab },
  { key = 'i', mods = 'CTRL|SHIFT', action = act.SwitchToWorkspace },
  { key = 's', mods = 'LEADER', action = act.ShowLauncherArgs { flags = 'FUZZY|WORKSPACES' } },
  { key = '[', mods = 'SUPER', action = act.ActivateTabRelative(-1) },
  { key = ']', mods = 'SUPER', action = act.ActivateTabRelative(1) },
  {
    key = ',',
    mods = 'LEADER',
    action = act.PromptInputLine {
      description = 'Enter new name for tab',
      action = wezterm.action_callback(function(window, pane, line)
        -- line is set only if enter is entered
        if line then window:active_tab():set_title(line) end
      end),
    },
  },
}

config.unix_domains = {
  { name = 'unix' },
}

config.default_gui_startup_args = { 'connect', 'unix' }

config.window_padding = {
  left = '1cell',
  right = '1cell',
  top = '0.5cell',
  bottom = '0.25cell',
}

return config

Expected Behavior

No response

Logs

No response

Anything else?

No response

@omar25h omar25h added the bug Something isn't working label Aug 6, 2023
@omar25h omar25h changed the title Screen redraw on macOS Screen redraw on macOS when using (Neo)vim Aug 6, 2023
@wez
Copy link
Owner

wez commented Aug 6, 2023

Please capture a terminal recording:

  • Launch wezterm. If possible, please use the default terminal size of 80x24 cells as it helps to keep things smaller and easier to manage.
  • Inside that terminal run wezterm record to start a recording session.
  • Run through your reproduction steps
  • Then type exit
  • You should see a message like:
*** Finished recording to /var/tmp/wezterm-recording-sF6B3u.cast.txt
  • Attach the file that it produced to this issue.

The file is an asciicast (compatible with https://asciinema.org/) and can also be replayed using wezterm replay.

The terminal recording allows me to replicate what is being sent to the terminal without requiring me to install the same applications as you and replicate your configuration for everything.

@wez wez added the waiting-on-op Waiting for more information from the original poster label Aug 6, 2023
@omar25h
Copy link
Author

omar25h commented Aug 6, 2023

@wez recording added

@github-actions github-actions bot removed the waiting-on-op Waiting for more information from the original poster label Aug 6, 2023
@omar25h
Copy link
Author

omar25h commented Sep 23, 2023

I got to realize that this happens only when connected to a UNIX domain. It does not happen when config.default_gui_startup_args = {}

@tjex
Copy link

tjex commented Nov 30, 2023

Also happening to me.

version nightly:
wezterm 20231128-074654-90ca1117

mac os 13.5 (going to upgrade soon...)

Also using yabai. But it happens with yabai disabled as well.

term.cast.txt

@shahamran
Copy link
Contributor

Happens to me as well, both on UNIX and SSHMUX sessions.

  • OS: vanilla macOS 14
  • wezterm: 20231203-124028-e3cd2e93
  • neovim: v0.10.0-dev-2008+g4ee656e4f

@eratio08
Copy link

Same issue

  • macOS 14.2.1 (23C71)
  • wezterm wezterm 20230712-072601-f4abf8fd
  • neovim v0.9.5

I'm also using the unix domain (like #4102 (comment))

config.unix_domains = { { name = 'unix' } }
config.default_gui_startup_args = { 'connect', 'unix' }

eratio08 added a commit to eratio08/dotfiles that referenced this issue Feb 24, 2024
It's currently broken on macos.
See wez/wezterm#4102
@tjex
Copy link

tjex commented Apr 26, 2024

Update. This is also effecting windows in general throughout various TUI apps of mine. Closed screens are simply left in place visually, and then drawn over once I start to move around / edit within the actual screen I'm supposed to be seeing.

Disabling mux totally for the moment as well which has rendered my launcher unusable as well as skhd spawn window global commands :( If anyone can point me towards where I can:

  • open tabs from the launch menu
  • spawn windows in the current workspace (afaik the --workspace flag in wezterm cli spawn cannot be assigned to current workspace, only default or a target)

@shahamran
Copy link
Contributor

Did anyone find a workaround? I really prefer (and rely on) wezterm's mux feature over tmux, but I can't use neovim inside it, which makes it unusable :(

jhthorsen added a commit to jhthorsen/dotfiles that referenced this issue May 23, 2024
@etiennecollin
Copy link

etiennecollin commented May 25, 2024

Hello!
Simply adding a comment because I too am affected by this issue on macOS 14.4.1. It makes wezterm unusable with neovim.

When I go into insert mode and make modifications, nothing appears/updates on the screen until I hit esc a few times which redraws the screen. Even in normal mode, when I move the cursor with hjkl or the arrows, the cursor does not move and only jumps to where it should be when I go into insert mode (moves are registered, but only drawn when changing mode redraws the window).

Note that this issue does not happen immediately for me, but after a certain amount of time (I haven't timed it).
It makes me think of the way a memory leak makes an app crash after a while.

I do not have this issue in iTerm2 with the same exact config otherwise.
Thank you if you are able to fix this and thank you for your amazing work!

Here is my config:

local config = {}

local wezterm = require("wezterm")
if wezterm.config_builder then
	config = wezterm.config_builder()
end

-- Configure looks
config.color_scheme = "Sonokai (Gogh)"
config.font = wezterm.font("JetBrains Mono", { weight = "Regular" })
config.font_size = 16

-- Configure window opacity
config.window_background_opacity = 1

config.inactive_pane_hsb = {
	saturation = 0.8,
	brightness = 0.7,
}

-- Config for window
config.hide_tab_bar_if_only_one_tab = true
config.window_frame = {
	font_size = 16,
}
config.window_decorations = "RESIZE"
config.window_padding = { left = 10, right = 10, top = 10, bottom = 0 }

-- Other settings
config.use_dead_keys = true
config.enable_scroll_bar = true
config.adjust_window_size_when_changing_font_size = false

return config

@artagnon
Copy link

As described in #5481, this bug reproduces with a simple sequence of dd and u (although up to five or six attempts may be required): unfortunately, the ascii screen capture doesn't show the bug. The bug is not reproducible on vim with the multiplexer, or on neovim without the multiplexer.

@etiennecollin
Copy link

I have recorded a brief example of the issue (I'll try to post a better one when I can, but as usual, these problems tend to occur when I'm not recording!). The issue is intermittent and challenging to diagnose, yet it happens quite frequently.

In my situation, everything is up to date, and I have encountered this issue on both macOS and Arch Linux.

This behavior occurs in both Neovim and the terminal itself. My recording is in Neovim, with an on-screen keylogger. If you play the video slowly, you can see that some actions are not displayed until another action is performed.

Here are some specifics from the recording:

  • First, when moving the cursor down, it doesn't move on the first press but jumps two lines on the second press.
    At around the 4-second mark, while in insert mode, I press escape, but the screen doesn't update to normal mode until I press the left arrow key.
  • Sometimes in insert mode, I can type without seeing any updates until I exit insert mode, at which point all the typed characters appear at once.

When this issue occurs in the terminal, I can type commands, but the letters do not appear until I hit enter a few times. Additionally, when a command produces output, the output does not appear unless I press a key on the keyboard.

Thank you for your help and your amazing terminal!
Here is the recording link for reference:

Screen.Recording.2024-06-14.at.15.22.45.mov

@Abdiramen
Copy link
Contributor

Abdiramen commented Jul 18, 2024

Happens to me as well, but on ssh sessions and on a different OS.

  • OS: NixOS 24.11pre650378.655a58a72a66 (Vicuna) x86_64
  • wezterm: 20240203-110809-5046fc22
  • neovim: v0.10.0

Worked around by setting multiplexing to None

config.ssh_domains = {
  -- rest of config here...
  multiplexing = 'None',
}

@lucasrabiec
Copy link

Same issue

  • macOS 14.2.1 (23C71)
  • wezterm wezterm 20230712-072601-f4abf8fd
  • neovim v0.9.5

I'm also using the unix domain (like #4102 (comment))

config.unix_domains = { { name = 'unix' } }
config.default_gui_startup_args = { 'connect', 'unix' }

Same for:

  • macOS 15.0
  • wezterm 20240203-110809-5046fc22
  • NVIM v0.10.1

@jacobb
Copy link

jacobb commented Oct 23, 2024

I also had this affecting me for quite a while.

I'm wondering if anyone has experienced this with a recent-ish nightly/main build.

#4607 has discussion around a similar combination (mux + neovim drawing) that has been resolved. I'm working against the source-built version from #5576 to test floating panes, and thought I would turn mux back on to see if it happened to fix this, and so far I have not hit it. Only a few hours of driving, though, so it's possible I'll hit it again. If so I can report back here.

@tjex
Copy link

tjex commented Nov 28, 2024

Update @loops has fixed a similar issue with #6186 . It could fix this issue to.
I can't test as I'm not on mac anymore. If someone could report back on the PR and quoting this issue number, would be ace.

@vohoanglong0107
Copy link

Thanks @loops for their work on this. Tested on Mac 15 with SSH multiplexing and it works wonders. It seems this issue can finally be resolved.

@wez wez added the fixed-in-nightly This is (or is assumed to be) fixed in the nightly builds. label Dec 7, 2024
@wez wez closed this as completed Dec 7, 2024
jhthorsen added a commit to jhthorsen/dotfiles that referenced this issue Dec 13, 2024
Copy link
Contributor

github-actions bot commented Jan 7, 2025

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jan 7, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working fixed-in-nightly This is (or is assumed to be) fixed in the nightly builds. multiplexer
Projects
None yet
Development

No branches or pull requests