MCPcopy Create free account
hub / github.com/cogentcore/core / CheckLexLine

Function CheckLexLine

spell/check.go:18–39  ·  view source on GitHub ↗

CheckLexLine returns the Lex regions for any words that are misspelled within given line of text with existing Lex tags -- automatically excludes any Code token regions (see token.IsCode). Token is set to token.TextSpellErr on returned Lex's

(src []rune, tags lexer.Line)

Source from the content-addressed store, hash-verified

16// excludes any Code token regions (see token.IsCode). Token is set
17// to token.TextSpellErr on returned Lex's
18func CheckLexLine(src []rune, tags lexer.Line) lexer.Line {
19 wrds := tags.NonCodeWords(src)
20 var ser lexer.Line
21 for _, t := range wrds {
22 wrd := string(t.Src(src))
23 lwrd := lexer.FirstWordApostrophe(wrd)
24 if len(lwrd) <= 2 {
25 continue
26 }
27 _, known := Spell.CheckWord(lwrd)
28 if !known {
29 t.Token.Token = token.TextSpellErr
30 widx := strings.Index(wrd, lwrd)
31 ld := len(wrd) - len(lwrd)
32 t.St += widx
33 t.Ed += widx - ld
34 t.Now()
35 ser = append(ser, t)
36 }
37 }
38 return ser
39}

Callers 1

SpellCheckLineErrorsMethod · 0.92

Calls 6

FirstWordApostropheFunction · 0.92
NonCodeWordsMethod · 0.80
SrcMethod · 0.80
CheckWordMethod · 0.80
IndexMethod · 0.45
NowMethod · 0.45

Tested by

no test coverage detected