Base of position index in main/ext interface

Hi folks,

I’ve noticed that we use line/character indices based on 1 for ranges and positions in packages/plugin-ext/src/api/model.ts. and …/plugin-api.ts.

This seems confusing to me. In the plugin API (both vscode and theia), in LSP and even in some of the theia internal classes (ProblemManager, for example); we use 0-based positions and ranges.

I feel it would be very helpful if we had a clear policy on this and would use the same base everywhere. I think it comes down to if theia is based on LSP (and related technologies) with Monaco as an implementation detail or if Monaco is our base and LSP, etc. are connectors to the outside world.

thoughts?

[original thread by Thomas Mäder]

vscode and monaco are using different indexes. So AFAIK in plug-in/extension it’s aligned with VSCode.


adding another link: https://github.com/Microsoft/vscode-languageserver-node/issues/88#issuecomment-245613746

I understand that those are different. However, which should be the primary representation in Theia? Should we do 0-based and convert when we move the data into Monaco? Or should we keep 1-based positions everywhere and therefore convert positions as soon as we get them from LSP or a vscode plugin?

In Theia we use LSP types as API, so 0-based

i think it is the case already

only when we work with Monaco positions are converted to 1-based