streetsidesoftware / cspell

A Spell Checker for Code!

Home Page:https://cspell.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How to get the entire word from the check result?

ch1ny opened this issue · comments

Hello, cspell is a nice project and it helps me a lot in my work.
And I'm making a tool for me to check my codes by using cspell-lib.

When I use cspell-lib to check spelling mistakes from the text such like const defaultProducDTO = {}, it returns me a issue like

{
    text: 'Produc',
    offset: 13,
    line: { text: 'const defaultProducDTO = {}', offset: 0 },
    isFlagged: false,
    isFound: false
}

Is there a way can I get the whole word defaultProducDTO from this line?

@ch1ny,

It doesn't currently return the whole symbol. But it is possible for you to figure it out based upon the result by taking the offset - line.offset and walking through the characters line.text looking for the first non-letter.

@ch1ny,

It doesn't currently return the whole symbol. But it is possible for you to figure it out based upon the result by taking the offset - line.offset and walking through the characters line.text looking for the first non-letter.

Thanks for the suggestion. I'm actually trying to extract the whole word by walking through the whole line.text .
But this tool might be used by my teammates, so I'm not sure would this be a stable way for their codes. XD
However, thanks for your help sincerely again.

By the way, I found a strange behavior yesterday.
I'm from China, so there may be many Chinese charactors in our codes.
If there were two wrong words connected by Chinese characters, the entire string would be recognized as wrong spelling.

image

This would also happen on Latin, Russian, Japanese etc.
I'm not sure if this is a by design behavior, but I think if this could be designed as an optional toggle might be help?

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.