diff --git a/src/server/features_formatting.v b/src/server/features_formatting.v index ac107a6..ea8fb88 100644 --- a/src/server/features_formatting.v +++ b/src/server/features_formatting.v @@ -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() } @@ -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 [