Skip to content

Commit

Permalink
fix Fix lsp formmat error in intellij. Change range from u32::Max to …
Browse files Browse the repository at this point in the history
…i32::Max

Signed-off-by: he1pa <[email protected]>
  • Loading branch information
He1pa committed Oct 18, 2024
1 parent a36e4d7 commit 2c421f4
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
8 changes: 5 additions & 3 deletions kclvm/tools/src/LSP/src/formatting.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}]))
Expand Down Expand Up @@ -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);
}

Expand Down
10 changes: 8 additions & 2 deletions kclvm/tools/src/LSP/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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()
Expand Down

0 comments on commit 2c421f4

Please sign in to comment.