OmniSharp / csharp-language-server-protocol

Language Server Protocol in C#
MIT License
514 stars 103 forks source link

Consider making Position(And possibly Range?) IComparable and adding more operator overloads #376

Closed ajaybhargavb closed 3 years ago

ajaybhargavb commented 3 years ago

It is fairly common to want to check whether a position appears before or after another and it would be nice to have them be easily comparable(like this) instead of having to check the line and character separately.

Here is an example of where this might be useful.

david-driscoll commented 3 years ago

I think that makes sense.

Should we apply the same thing to Range as well?

ajaybhargavb commented 3 years ago

Should we apply the same thing to Range as well?

We haven't found the need for it yet. Maybe not given Roslyn doesn't do that either, https://github.com/dotnet/roslyn/blob/master/src/Compilers/Core/Portable/Text/LinePositionSpan.cs.

ajaybhargavb commented 3 years ago

Thanks @david-driscoll