terminal: fix tests for brackets on selectWord

This commit is contained in:
Mitchell Hashimoto
2024-03-04 14:30:28 -08:00
parent 59485713b4
commit eaa78477d5

View File

@ -1739,7 +1739,26 @@ pub fn selectWordBetween(
/// this happens is if the point pt is outside of the written screen space. /// this happens is if the point pt is outside of the written screen space.
pub fn selectWord(self: *Screen, pt: point.ScreenPoint) ?Selection { pub fn selectWord(self: *Screen, pt: point.ScreenPoint) ?Selection {
// Boundary characters for selection purposes // Boundary characters for selection purposes
const boundary = &[_]u32{ 0, ' ', '\t', '\'', '"', '│', '`', '|', ':', ',', '(', ')', '[', ']', '{', '}', '<', '>' }; const boundary = &[_]u32{
0,
' ',
'\t',
'\'',
'"',
'│',
'`',
'|',
':',
',',
'(',
')',
'[',
']',
'{',
'}',
'<',
'>',
};
// Impossible to select anything outside of the area we've written. // Impossible to select anything outside of the area we've written.
const y_max = self.rowsWritten() - 1; const y_max = self.rowsWritten() - 1;
@ -4770,9 +4789,6 @@ test "Screen: selectWord with character boundary" {
const testing = std.testing; const testing = std.testing;
const alloc = testing.allocator; const alloc = testing.allocator;
var s = try init(alloc, 10, 20, 0);
defer s.deinit();
const cases = [_][]const u8{ const cases = [_][]const u8{
" 'abc' \n123", " 'abc' \n123",
" \"abc\" \n123", " \"abc\" \n123",
@ -4783,16 +4799,17 @@ test "Screen: selectWord with character boundary" {
" ,abc, \n123", " ,abc, \n123",
" (abc( \n123", " (abc( \n123",
" )abc) \n123", " )abc) \n123",
// " [abc[ \n123", " [abc[ \n123",
// " ]abc] \n123", " ]abc] \n123",
// " {abc{ \n123", " {abc{ \n123",
// " }abc} \n123", " }abc} \n123",
// " <abc< \n123", " <abc< \n123",
// " >abc> \n123", " >abc> \n123",
}; };
for (cases) |case| { for (cases) |case| {
try s.clear(.history); var s = try init(alloc, 10, 20, 0);
defer s.deinit();
try s.testWriteString(case); try s.testWriteString(case);
// Inside character forward // Inside character forward