language-tools
language-tools copied to clipboard
Integer.MAX_VALUE is not portable across clients
Bug description
The following places use numbers that are too large for the LSP spec's uinteger type, which can have max value 2^32 - 1.
https://github.com/prisma/language-tools/blob/c464b8f5a785d67b06da6bf3f273c7eafacdccb2/packages/language-server/src/rename/renameUtil.ts#L186
https://github.com/prisma/language-tools/blob/c464b8f5a785d67b06da6bf3f273c7eafacdccb2/packages/language-server/src/rename/renameUtil.ts#L190
https://github.com/sublimelsp/LSP/issues/1951#issuecomment-1071391571 (note that you cannot use Number.MAX_SAFE_INTEGER)
How to reproduce
Run the "rename" request in Sublime Text.
Observe stack trace:
Traceback (most recent call last):
File "C:\Sublime Text\Lib\python33\sublime_plugin.py", line 1488, in run_
return self.run(edit, **args)
File "C:\Users\DELL\AppData\Roaming\Sublime Text\Installed Packages\LSP.sublime-package\plugin/edit.py", line 38, in run
File "C:\Sublime Text\Lib\python33\sublime.py", line 1493, in text_point_utf16
return sublime_api.view_text_point_utf16(self.view_id, row, col_utf16, clamp_column)
OverflowError: int too big to convert
Expected behavior
Rename works.
Minor correction, but the uinteger max value is defined to be 2^31 - 1, not 2^32 - 1.
Hmm, I'm not the most familiar with Sublime here but I installed it so I could take a look. But it seems to be working for me?
These are the packages I installed after getting a fresh Sublime (Stable Channel, Build 4143) through Homebrew

Could you please verify if this is still happening for you @rwols?
We guard for this here: https://github.com/sublimelsp/LSP/pull/1952
Prisma should still fix this, as it's a spec violation and may result in bad behavior in other text editors.
Hi everybody! I'm from the IntelliJ WebStorm team and just several days ago we released a new plugin that supports Prisma ORM.
This issue backfired quite hard, because we use the java library lsp4j for the LSP integration, and the Range type fields are defined as 32-bit integers, which conforms to the specification. So, we have an exception during the deserialization of the response and can't really do anything about it on our side 😢.
There are only several usages of Number.MAX_SAFE_INTEGER or Number.MAX_VALUE, so it shouldn't be hard to fix. Otherwise, it looks like such issues also will occur in other java based IDEs. Thank you in advance!
https://github.com/prisma/language-tools/blob/673adcd173fb66c7d831d06889459e444e5374fd/packages/language-server/src/diagnosticsHandler.ts#L27 https://github.com/prisma/language-tools/blob/673adcd173fb66c7d831d06889459e444e5374fd/packages/language-server/src/util.ts#L26 https://github.com/prisma/language-tools/blob/673adcd173fb66c7d831d06889459e444e5374fd/packages/language-server/src/util.ts#L33 https://github.com/prisma/language-tools/blob/673adcd173fb66c7d831d06889459e444e5374fd/packages/language-server/src/MessageHandler.ts#L222