change comments to English

This commit is contained in:
2026-03-24 13:40:29 +00:00
parent 66f34eeb58
commit 912b9b0075
8 changed files with 61 additions and 62 deletions
@@ -5,22 +5,22 @@ fn text_index_ascii_roundtrip() {
let text = "hello\nworld\nthis is ascii";
let idx = TextIndex::new(text);
// Verifica round-trip em todas as fronteiras de char
// Verify round-trip on all character boundaries
let mut boundaries: Vec<usize> = text.char_indices().map(|(i, _)| i).collect();
boundaries.push(text.len());
for &b in &boundaries {
let (line, col16) = idx.byte_to_lsp(b as u32);
let b2 = idx.lsp_to_byte(line, col16);
assert_eq!(b2, b as u32, "roundtrip falhou para byte {} -> (l={},c16={})", b, line, col16);
assert_eq!(b2, b as u32, "roundtrip failed for byte {} -> (l={},c16={})", b, line, col16);
}
// Alguns checks diretos
// início: (0,0)
// Some direct checks
// start: (0,0)
assert_eq!(idx.byte_to_lsp(0), (0, 0));
// após "hello" (5), antes do '\n': linha 0, col=5
// after "hello" (5), before '\n': line 0, col=5
assert_eq!(idx.byte_to_lsp(5), (0, 5));
// após '\n' (6): linha 1, col=0
// after '\n' (6): line 1, col=0
assert_eq!(idx.byte_to_lsp(6), (1, 0));
}
@@ -30,25 +30,25 @@ fn text_index_unicode_roundtrip_utf16() {
let text = "aé🙂b";
let idx = TextIndex::new(text);
// fronteiras de char + fim
// character boundaries + end
let mut boundaries: Vec<usize> = text.char_indices().map(|(i, _)| i).collect();
boundaries.push(text.len());
for &b in &boundaries {
let (line, col16) = idx.byte_to_lsp(b as u32);
let b2 = idx.lsp_to_byte(line, col16);
assert_eq!(b2, b as u32, "roundtrip unicode falhou para byte {} -> (l={},c16={})", b, line, col16);
assert_eq!(b2, b as u32, "unicode roundtrip failed for byte {} -> (l={},c16={})", b, line, col16);
}
// Checagens de colunas esperadas na linha 0
// Expected columns on line 0
// bytes: [0:'a'][1..2:'é'][3..6:'🙂'][7:'b'][8:end]
assert_eq!(idx.byte_to_lsp(0), (0, 0)); // antes de 'a'
assert_eq!(idx.byte_to_lsp(1), (0, 1)); // após 'a'
assert_eq!(idx.byte_to_lsp(3), (0, 2)); // após 'a' + 'é' (1+1 utf16)
assert_eq!(idx.byte_to_lsp(7), (0, 4)); // após '🙂' (2 utf16) => 1+1+2=4
assert_eq!(idx.byte_to_lsp(8), (0, 5)); // após 'b'
assert_eq!(idx.byte_to_lsp(0), (0, 0)); // before 'a'
assert_eq!(idx.byte_to_lsp(1), (0, 1)); // after 'a'
assert_eq!(idx.byte_to_lsp(3), (0, 2)); // after 'a' + 'é' (1+1 utf16)
assert_eq!(idx.byte_to_lsp(7), (0, 4)); // after '🙂' (2 utf16) => 1+1+2=4
assert_eq!(idx.byte_to_lsp(8), (0, 5)); // after 'b'
// e inverso, colunas específicas
// and inverse, specific columns
assert_eq!(idx.lsp_to_byte(0, 0), 0);
assert_eq!(idx.lsp_to_byte(0, 1), 1);
assert_eq!(idx.lsp_to_byte(0, 2), 3);