diff --git a/kclvm/tools/src/LSP/src/formatting.rs b/kclvm/tools/src/LSP/src/formatting.rs index 383e101fe..0b7833af4 100644 --- a/kclvm/tools/src/LSP/src/formatting.rs +++ b/kclvm/tools/src/LSP/src/formatting.rs @@ -19,7 +19,7 @@ pub fn format( Ok(Some(vec![TextEdit { range: range.unwrap_or(Range::new( Position::new(0, 0), - Position::new(u32::MAX, u32::MAX), + Position::new(i32::MAX as u32, i32::MAX as u32), )), new_text: source, }])) @@ -92,10 +92,12 @@ mod tests { let data_output = data_output.replace("\r\n", "\n"); let expect = vec![TextEdit { - range: Range::new(Position::new(0, 0), Position::new(u32::MAX, u32::MAX)), + range: Range::new( + Position::new(0, 0), + Position::new(i32::MAX as u32, i32::MAX as u32), + ), new_text: data_output, }]; - println!("{:?}", test_file); assert_eq!(expect, got); } diff --git a/kclvm/tools/src/LSP/src/tests.rs b/kclvm/tools/src/LSP/src/tests.rs index 676b58df0..a199ca95c 100644 --- a/kclvm/tools/src/LSP/src/tests.rs +++ b/kclvm/tools/src/LSP/src/tests.rs @@ -1328,7 +1328,10 @@ fn formatting_test() { assert_eq!( res.result.unwrap(), to_json(Some(vec![TextEdit { - range: Range::new(Position::new(0, 0), Position::new(u32::MAX, u32::MAX),), + range: Range::new( + Position::new(0, 0), + Position::new(i32::MAX as u32, i32::MAX as u32), + ), new_text: "a = 1\n\nb = 2\n\nc = 3\n\nd = 4\n".to_string() }])) .unwrap() @@ -1399,7 +1402,10 @@ fn formatting_unsaved_test() { assert_eq!( res.result.unwrap(), to_json(Some(vec![TextEdit { - range: Range::new(Position::new(0, 0), Position::new(u32::MAX, u32::MAX),), + range: Range::new( + Position::new(0, 0), + Position::new(i32::MAX as u32, i32::MAX as u32), + ), new_text: "unsaved = 0\n\na = 1\n\nb = 2\n\nc = 3\n\nd = 4\n".to_string() }])) .unwrap()