-
Notifications
You must be signed in to change notification settings - Fork 13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix hanging on windows #130
base: main
Are you sure you want to change the base?
Conversation
// test_file := 'file:///c%3A/Users/phcre/Documents/v/imageeditor/testing/proc.v' | ||
dump(test_file) | ||
|
||
src := os.read_file(test_file) or { panic('Cannot read file') } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
os.read_file handles relative and absolute paths, like the ones returned by os.real_path .
src/server/features_formatting.v
Outdated
mut fmt_proc := ls.launch_tool('fmt', temp_formatting_file_path)! | ||
loglib.info('Formatting file: ${temp_formatting_file_path} ${file.uri}') | ||
|
||
mut fmt_proc := ls.launch_tool('fmt', os.norm_path(temp_formatting_file_path)) or { return [] } | ||
defer { | ||
fmt_proc.close() | ||
} | ||
fmt_proc.run() | ||
|
||
// read entire output until EOF | ||
mut output := fmt_proc.stdout_slurp() | ||
fmt_proc.wait() | ||
|
||
if fmt_proc.code != 0 { | ||
loglib.info('Formatting finished with code: ${fmt_proc.code} and status ${fmt_proc.status}') | ||
|
||
$if windows { | ||
output = output.replace('\r\r', '\r') | ||
} | ||
|
||
if (fmt_proc.code != 0) && (fmt_proc.status == .exited) { | ||
errors := fmt_proc.stderr_slurp().trim_space() | ||
ls.client.show_message(errors, .info) | ||
return error('Formatting failed: ${errors}') | ||
// return [] | ||
} | ||
|
||
mut output := fmt_proc.stdout_slurp() | ||
$if windows { | ||
output = output.replace('\r\r', '\r') | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
that is complicated for no reason. Just res := os.execute('v fmt file.v')
and then using res.exit_code
and res.output
should be enough.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is the goal avoiding reading from stderr?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did not write this originally but I believe that is the case. the stdout gets sent to the IDE and is used to replace the text in the buffer. the stderr, if caught, gets sent to the IDE as a warning notification/highlighting. I do think os.execute would work but it is essentially the same thing
fix #128
vfmt on large files fills the stdout output buffer but v-analyzer does not read the buffer until vfmt exits.