Skip to content

Some code tools return "\r\n" on Windows. #130

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

Closed
UnderCooled opened this issue Jan 12, 2024 · 4 comments
Closed

Some code tools return "\r\n" on Windows. #130

UnderCooled opened this issue Jan 12, 2024 · 4 comments
Labels
bug Something isn't working

Comments

@UnderCooled
Copy link

This is codespell diagnostic message:

image

These "^M" are "\r" characters, but not all code tools will use "\r\n" on Windows, maybe user should define a parse function to filter out these "^M"?

Tools without json output may have this issue on Windows, so guard can also fix it in diag_fmt function.

message = message or '',

message = message and message:gsub('\r', '') or ''

or with an OS check if?

@xiaoshihou514
Copy link
Collaborator

xiaoshihou514 commented Jan 12, 2024

Seems like a CRLF issue, I wonder if nvim_replace_termcode would fix it

@UnderCooled
Copy link
Author

UnderCooled commented Jan 12, 2024

I think Python-based tools have this problem.

Reference: python/cpython#57328

我接下来用中文表达,英文不是太好。现代三大系统应该就 Windows 还在用 "\r" 了,现在的代码把工具输出的信息按 "\n" 分割后解析成行号列号消息等等,那么这个 "\r" 出现在消息之中是不是应该除了某些工具为了兼容 Windows 的命令行窗口之外没有什么用处。但可能某个 linter 检查代码时,发现代码中有触发什么 "\r" 规则,而返回了一行诊断信息中包含了 "\r" 的提示信息(不过这样的信息是不是也应该是已经转义的 \\r 呢),那么只删掉消息中处于最末端的 "\r" 应该不会引发什么问题吧。

@xiaoshihou514
Copy link
Collaborator

I was hoping there is a generic function that would handle these platform dependent quirks, which would also fix other potential CRLF related issues 🤔 But if there isn't one maybe we could apply the monkey patch you described 👍

@xiaoshihou514 xiaoshihou514 added the bug Something isn't working label Jan 12, 2024
@xiaoshihou514
Copy link
Collaborator

Ah, vim.split takes regexes, so vim.split("\r?\n") would solve this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants