Skip to content

Commit 4164afe

Browse files
committed
Worked out the fiddly
1 parent a51a8e6 commit 4164afe

File tree

5 files changed

+19
-16
lines changed

5 files changed

+19
-16
lines changed

codebook/src/lib.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,7 @@ impl CodeDictionary {
249249
let current_line = node_start.row as u32;
250250
let current_column = node_start.column as u32;
251251
let words = self.get_words_from_text(node_text);
252+
println!("Found Capture:: {node_text:?}");
252253
println!("Words:: {words:?}");
253254
println!("Column: {current_column}");
254255
println!("Line: {current_line}");
@@ -257,7 +258,8 @@ impl CodeDictionary {
257258
println!("Checking: {:?}", split);
258259
for split_word in split {
259260
if !self.check(&split_word.word) {
260-
let base_start_char = text_start_char + current_column;
261+
let offset = if text_line == 0 { current_column } else { 0 };
262+
let base_start_char = text_start_char + offset;
261263
let location = TextRange {
262264
start_char: base_start_char + split_word.start_char,
263265
end_char: base_start_char

codebook/src/queries.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ pub static LANGUAGE_SETTINGS: [LanguageSetting; 7] = [
1111
pattern: (identifier) @identifier)
1212
(let_declaration
1313
pattern: (identifier) @identifier)
14+
(line_comment) @comment
1415
(string_content) @string
1516
(char_literal) @string
1617
"#,

codebook/tests/test_go.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,16 @@ mod utils;
55
#[test]
66
fn test_go_location() {
77
let sample_text = r#"
8-
func mispeledFuncion() string {
9-
return ""
10-
}"#;
8+
func mispeledFuncion() string {
9+
return ""
10+
}"#;
1111
let expected = vec![
1212
SpellCheckResult::new(
1313
"mispeled".to_string(),
1414
vec!["misspelled", "dispelled", "misspell", "misled"],
1515
vec![TextRange {
16-
start_char: 13,
17-
end_char: 21,
16+
start_char: 9,
17+
end_char: 17,
1818
start_line: 1,
1919
end_line: 1,
2020
}],
@@ -23,8 +23,8 @@ fn test_go_location() {
2323
"Funcion".to_string(),
2424
vec!["Function"],
2525
vec![TextRange {
26-
start_char: 21,
27-
end_char: 28,
26+
start_char: 17,
27+
end_char: 24,
2828
start_line: 1,
2929
end_line: 1,
3030
}],

codebook/tests/test_python.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@ mod utils;
66
fn test_python_simple() {
77
let processor = utils::get_processor();
88
let sample_text = r#"
9-
def calculat_user_age(bithDate: str) -> int:
9+
def calculat_user_age(bithDate) -> int:
1010
# This is an examle_function that calculates age
1111
usrAge = get_curent_date() - bithDate
1212
userAge
1313
"#;
14-
let expected = vec!["bith", "calculat", "examle", "usr"];
15-
let binding = processor.spell_check(sample_text, "rust").to_vec();
14+
let expected = vec!["bith", "calculat", "curent", "examle", "usr"];
15+
let binding = processor.spell_check(sample_text, "python").to_vec();
1616
let mut misspelled = binding
1717
.iter()
1818
.map(|r| r.word.as_str())
@@ -45,10 +45,10 @@ multi_line_comment = '''
4545
"linet".to_string(),
4646
vec![],
4747
vec![TextRange {
48-
start_char: 57,
49-
end_char: 62,
50-
start_line: 2,
51-
end_line: 2,
48+
start_char: 12,
49+
end_char: 17,
50+
start_line: 3,
51+
end_line: 3,
5252
}],
5353
),
5454
];

codebook/tests/test_rust.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use codebook::{SpellCheckResult, TextRange};
22

33
mod utils;
4-
4+
// im a bd speler
55
#[test]
66
fn test_rust_simple() {
77
let processor = utils::get_processor();

0 commit comments

Comments
 (0)