Skip to content

Commit

Permalink
buf fix for format on lines less than preious
Browse files Browse the repository at this point in the history
  • Loading branch information
hapeeeeee committed Jan 30, 2024
1 parent 11d0f6e commit 138e828
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion language/move-analyzer/src/movefmt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,18 @@ pub fn on_movefmt_request(context: &Context, request: &Request, fmt_cfg: &FmtCon
movefmt_cfg.set().max_width(fmt_cfg.max_width as usize);
movefmt_cfg.set().indent_size(fmt_cfg.indent_size as usize);
let content_format = movefmt::core::fmt::format_entry(content_origin.clone(), movefmt_cfg).unwrap();

let result_line =
if content_format.clone().lines().count() >= content_origin.clone().lines().count() {
content_format.clone().lines().count()
} else {
content_origin.clone().lines().count()
};

let result = Some(vec![TextEdit {
range: lsp_types::Range {
start: Position { line: 0, character: 0 },
end: Position { line: content_format.clone().lines().count() as u32, character: 0 },
end: Position { line: result_line as u32, character: 0 },
},
new_text: content_format,
}]);
Expand Down

0 comments on commit 138e828

Please sign in to comment.