Projects STRLCPY alacritty Commits f1be6804
🤬
  • Fix fullwidth char regex search infinite loop

    This resolves an issue where the regex search could loop indefinitely
    when the end point was defined in a location containing a fullwidth
    character, thus skipping over the end before termination.
    
    Fixes #5753.
  • Loading...
  • Christian Duerr committed 2 years ago
    f1be6804
    1 parent d86e79f1
Revision indexing in progress... (symbol navigation in revisions will be accurate after indexed)
  • ■ ■ ■ ■ ■
    CHANGELOG.md
    skipped 38 lines
    39 39  - Freeze when the vi cursor is on the scrollback and scrollback clear is invoked
    40 40  - Vi cursor on topmost of the display moving downward when scrolled into history with active output
    41 41  - Input lag on Wayland with Nvidia binary driver
     42 +- Crash when hovering the mouse over fullwidth characters
    42 43   
    43 44  ### Removed
    44 45   
    skipped 926 lines
  • ■ ■ ■ ■ ■ ■
    alacritty_terminal/src/term/search.rs
    skipped 204 lines
    205 205   let mut state = dfa.start_state();
    206 206   let mut last_wrapped = false;
    207 207   let mut regex_match = None;
     208 + let mut done = false;
    208 209   
    209 210   let mut cell = iter.cell();
    210 211   self.skip_fullwidth(&mut iter, &mut cell, direction);
    skipped 28 lines
    239 240   }
    240 241   
    241 242   // Stop once we've reached the target point.
    242  - if point == end {
     243 + if point == end || done {
    243 244   break;
    244 245   }
    245 246   
    skipped 8 lines
    254 255   iter.cell()
    255 256   },
    256 257   };
     258 + 
     259 + // Check for completion before potentially skipping over fullwidth characters.
     260 + done = iter.point() == end;
     261 + 
    257 262   self.skip_fullwidth(&mut iter, &mut cell, direction);
     263 + 
    258 264   let wrapped = cell.flags.contains(Flags::WRAPLINE);
    259 265   c = cell.c;
    260 266   
    skipped 437 lines
    698 704   let start = Point::new(Line(0), Column(1));
    699 705   let end = Point::new(Line(0), Column(0));
    700 706   assert_eq!(term.regex_search_left(&dfas, start, end), Some(end..=start));
     707 + }
     708 + 
     709 + #[test]
     710 + fn end_on_fullwidth() {
     711 + let term = mock_term("jarr🦇");
     712 + 
     713 + let start = Point::new(Line(0), Column(0));
     714 + let end = Point::new(Line(0), Column(4));
     715 + 
     716 + // Ensure ending without a match doesn't loop indefinitely.
     717 + let dfas = RegexSearch::new("x").unwrap();
     718 + assert_eq!(term.regex_search_right(&dfas, start, end), None);
     719 + 
     720 + let dfas = RegexSearch::new("x").unwrap();
     721 + let match_end = Point::new(Line(0), Column(5));
     722 + assert_eq!(term.regex_search_right(&dfas, start, match_end), None);
     723 + 
     724 + // Ensure match is captured when only partially inside range.
     725 + let dfas = RegexSearch::new("jarr🦇").unwrap();
     726 + assert_eq!(term.regex_search_right(&dfas, start, end), Some(start..=match_end));
    701 727   }
    702 728   
    703 729   #[test]
    skipped 124 lines
Please wait...
Page is in error, reload to recover