caretAtStatementStart reports whether the caret is at a statement-start position — only whitespace and comments precede it (or it directly follows a ';'), ignoring any partial identifier the user is currently typing (so "CRE" or "...; INS" still count as statement start). Write keywords are filtered
(statement string, pos int)
| 406 | // only here (in the query scene) so keywords valid inside read statements are |
| 407 | // preserved in other positions. |
| 408 | func caretAtStatementStart(statement string, pos int) bool { |
| 409 | if pos > len(statement) { |
| 410 | pos = len(statement) |
| 411 | } |
| 412 | before := stripStringsAndComments(statement)[:pos] |
| 413 | before = strings.TrimRight(before, identifierChars) // drop the partial identifier |
| 414 | before = strings.TrimRight(before, " \t\r\n") |
| 415 | return before == "" || before[len(before)-1] == ';' |
| 416 | } |
| 417 | |
| 418 | func caretInsideBacktickIdentifier(statement string, pos int) bool { |
| 419 | if pos > len(statement) { |
no test coverage detected