Skip to content

Commit

Permalink
revert: return error on launch_tool v fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
phcreery committed Oct 3, 2024
1 parent 99c5702 commit 2aa7900
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/server/features_formatting.v
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,15 @@ pub fn (mut ls LanguageServer) formatting(params lsp.DocumentFormattingParams) !
uri := params.text_document.uri.normalize()
file := ls.get_file(uri) or { return error('Cannot format not opened file') }

os.write_file(temp_formatting_file_path, file.psi_file.source_text)!
os.write_file(temp_formatting_file_path, file.psi_file.source_text) or {
return error('Cannot write temp file for formatting: ${err}')
}

loglib.with_fields({
'uri': file.uri.str()
}).info('Formatting file')

mut fmt_proc := ls.launch_tool('fmt', os.norm_path(temp_formatting_file_path)) or { return [] }
mut fmt_proc := ls.launch_tool('fmt', os.norm_path(temp_formatting_file_path))!
defer {
fmt_proc.close()
}
Expand All @@ -40,6 +42,7 @@ pub fn (mut ls LanguageServer) formatting(params lsp.DocumentFormattingParams) !
errors := fmt_proc.stderr_slurp().trim_space()
ls.client.show_message(errors, .info)
return error('Formatting failed: ${errors}')
// return []
}

return [
Expand Down

0 comments on commit 2aa7900

Please sign in to comment.