atom-haskell / ide-haskell-hasktags

Hasktags-powered replacement for symbols-view on Haskell projects
https://atom.io/packages/ide-haskell-hasktags
MIT License
6 stars 2 forks source link

Fix getting a wrong crange when going to declaration #12

Closed dplusic closed 7 years ago

dplusic commented 7 years ago

If the word you want to find is at the end of the line, cannot get a right crange.

lierdakil commented 7 years ago

Thanks.

TBH, this code should've been rewritten ages ago. For one, [\w'] regexp isn't all that good to begin with, e.g. it won't work for Unicode or operators. Approach used in https://github.com/atom-haskell/haskell-debug/blob/master/src/lib/TooltipOverride.ts#L7 could be a better option, but choosing which grammar scopes to check is a non-trivial question (e.g. types are not identifier.haskell)

Another option would be to fix regex similar to https://github.com/atom-haskell/autocomplete-haskell/blob/master/src/opertator-regex.ts -- with a few changes, due to hasktags not understanding qualified prefixes. https://github.com/atom-haskell/language-haskell/blob/master/src/include/macros.coffee#L4 might be relevant for what characters can be in a Haskell identifier/type/etc. Something to the tune of [\p{Ll}_\p{Lu}\p{Lt}\p{Nd}'] should work reasonably well, I think.

If you can't (or don't want to) spend any more time on this, I can merge as-is, and later rewrite it when I have time -- might be a while.

dplusic commented 7 years ago

Thank you for your suggestion! I'll try it later.