Fix vi indicator obstructing vi mode cursor

Fixes #5504.
This commit is contained in:
Christian Duerr 2021-09-27 03:51:58 +00:00 committed by GitHub
parent 58985a4dcb
commit b6e05d2dce
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 3 deletions

View File

@ -17,6 +17,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
- Config option `background_opacity`, you should use `window.opacity` instead - Config option `background_opacity`, you should use `window.opacity` instead
- Reload configuration files when their symbolic link is replaced - Reload configuration files when their symbolic link is replaced
### Fixed
- Line indicator obstructing vi mode cursor when scrolled into history
## 0.9.0 ## 0.9.0
### Packaging ### Packaging

View File

@ -544,7 +544,10 @@ impl Display {
// Indicate vi mode by showing the cursor's position in the top right corner. // Indicate vi mode by showing the cursor's position in the top right corner.
let vi_point = vi_mode_cursor.point; let vi_point = vi_mode_cursor.point;
let line = (-vi_point.line.0 + size_info.bottommost_line().0) as usize; let line = (-vi_point.line.0 + size_info.bottommost_line().0) as usize;
self.draw_line_indicator(config, &size_info, total_lines, Some(vi_point), line); let obstructed_column = Some(vi_point)
.filter(|point| point.line == -(display_offset as i32))
.map(|point| point.column);
self.draw_line_indicator(config, &size_info, total_lines, obstructed_column, line);
} else if search_state.regex().is_some() { } else if search_state.regex().is_some() {
// Show current display offset in vi-less search to indicate match position. // Show current display offset in vi-less search to indicate match position.
self.draw_line_indicator(config, &size_info, total_lines, None, display_offset); self.draw_line_indicator(config, &size_info, total_lines, None, display_offset);
@ -777,7 +780,7 @@ impl Display {
config: &Config, config: &Config,
size_info: &SizeInfo, size_info: &SizeInfo,
total_lines: usize, total_lines: usize,
vi_mode_point: Option<Point>, obstructed_column: Option<Column>,
line: usize, line: usize,
) { ) {
let text = format!("[{}/{}]", line, total_lines - 1); let text = format!("[{}/{}]", line, total_lines - 1);
@ -787,7 +790,7 @@ impl Display {
let bg = colors.line_indicator.background.unwrap_or(colors.primary.foreground); let bg = colors.line_indicator.background.unwrap_or(colors.primary.foreground);
// Do not render anything if it would obscure the vi mode cursor. // Do not render anything if it would obscure the vi mode cursor.
if vi_mode_point.map_or(true, |point| point.line != 0 || point.column < column) { if obstructed_column.map_or(true, |obstructed_column| obstructed_column < column) {
let glyph_cache = &mut self.glyph_cache; let glyph_cache = &mut self.glyph_cache;
self.renderer.with_api(&config.ui_config, size_info, |mut api| { self.renderer.with_api(&config.ui_config, size_info, |mut api| {
api.render_string(glyph_cache, Point::new(0, column), fg, bg, &text); api.render_string(glyph_cache, Point::new(0, column), fg, bg, &text);