mirror of
				https://github.com/neovim/neovim.git
				synced 2025-11-04 01:34:25 +00:00 
			
		
		
		
	fix(extui): hide inactive "more" window (#33831)
Problem:  More-window is left visible after leaving it. Cursor may be
          hidden behind it and it is hard to re-enter afterwards.
Solution: Close the more-window when another window is entered.
			
			
This commit is contained in:
		@@ -69,7 +69,7 @@ function M.enable(opts)
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
  -- Use MsgArea and hide search highlighting in the cmdline window.
 | 
					  -- Use MsgArea and hide search highlighting in the cmdline window.
 | 
				
			||||||
  -- TODO: Add new highlight group/namespaces for other windows? It is
 | 
					  -- TODO: Add new highlight group/namespaces for other windows? It is
 | 
				
			||||||
  -- clear MsgArea would be wanted in the box, more and prompt windows.
 | 
					  -- not clear if MsgArea is wanted in the box, more and prompt windows.
 | 
				
			||||||
  api.nvim_set_hl(ext.ns, 'Normal', { link = 'MsgArea' })
 | 
					  api.nvim_set_hl(ext.ns, 'Normal', { link = 'MsgArea' })
 | 
				
			||||||
  api.nvim_set_hl(ext.ns, 'Search', { link = 'MsgArea' })
 | 
					  api.nvim_set_hl(ext.ns, 'Search', { link = 'MsgArea' })
 | 
				
			||||||
  api.nvim_set_hl(ext.ns, 'CurSearch', { link = 'MsgArea' })
 | 
					  api.nvim_set_hl(ext.ns, 'CurSearch', { link = 'MsgArea' })
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -112,12 +112,11 @@ local function set_virttext(type)
 | 
				
			|||||||
      end
 | 
					      end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      -- Give virt_text the same highlight as the message tail.
 | 
					      -- Give virt_text the same highlight as the message tail.
 | 
				
			||||||
      local hl = api.nvim_buf_get_extmarks(ext.bufs[tar], ext.ns, { row, col }, { row, col }, {
 | 
					      local pos, opts = { row, col }, { details = true, overlap = true, type = 'highlight' }
 | 
				
			||||||
        details = true,
 | 
					      local hl = api.nvim_buf_get_extmarks(ext.bufs[tar], ext.ns, pos, pos, opts)
 | 
				
			||||||
        overlap = true,
 | 
					      for _, chunk in ipairs(hl[1] and chunks or {}) do
 | 
				
			||||||
        type = 'highlight',
 | 
					        chunk[2] = hl[1][4].hl_group
 | 
				
			||||||
      })
 | 
					      end
 | 
				
			||||||
      chunks[1][2] = hl[1] and hl[1][4].hl_group
 | 
					 | 
				
			||||||
    else
 | 
					    else
 | 
				
			||||||
      local mode = #M.virt.last[M.virt.idx.mode]
 | 
					      local mode = #M.virt.last[M.virt.idx.mode]
 | 
				
			||||||
      local pad = o.columns - width ---@type integer
 | 
					      local pad = o.columns - width ---@type integer
 | 
				
			||||||
@@ -392,6 +391,15 @@ function M.set_pos(type)
 | 
				
			|||||||
      local row = (texth.all > height and texth.end_row or 0) + 1
 | 
					      local row = (texth.all > height and texth.end_row or 0) + 1
 | 
				
			||||||
      api.nvim_win_set_cursor(ext.wins[ext.tab].box, { row, 0 })
 | 
					      api.nvim_win_set_cursor(ext.wins[ext.tab].box, { row, 0 })
 | 
				
			||||||
    elseif type == 'more' and api.nvim_get_current_win() ~= win then
 | 
					    elseif type == 'more' and api.nvim_get_current_win() ~= win then
 | 
				
			||||||
 | 
					      api.nvim_create_autocmd('WinEnter', {
 | 
				
			||||||
 | 
					        once = true,
 | 
				
			||||||
 | 
					        callback = function()
 | 
				
			||||||
 | 
					          if api.nvim_win_is_valid(win) then
 | 
				
			||||||
 | 
					            api.nvim_win_set_config(win, { hide = true })
 | 
				
			||||||
 | 
					          end
 | 
				
			||||||
 | 
					        end,
 | 
				
			||||||
 | 
					        desc = 'Hide inactive more window.',
 | 
				
			||||||
 | 
					      })
 | 
				
			||||||
      api.nvim_set_current_win(win)
 | 
					      api.nvim_set_current_win(win)
 | 
				
			||||||
    end
 | 
					    end
 | 
				
			||||||
  end
 | 
					  end
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user