MCPcopy Create free account
hub / github.com/bytebase/bytebase / catchCaretLineColumn

Function catchCaretLineColumn

backend/plugin/parser/mysql/completion_test.go:145–163  ·  view source on GitHub ↗

catchCaretLineColumn returns the SQL without the caret marker and the 1-based line + 0-based column of the caret position. Handles multiline input.

(s string)

Source from the content-addressed store, hash-verified

143// catchCaretLineColumn returns the SQL without the caret marker and the
144// 1-based line + 0-based column of the caret position. Handles multiline input.
145func catchCaretLineColumn(s string) (string, int, int) {
146 for i, c := range s {
147 if c == '|' {
148 text := s[:i] + s[i+1:]
149 line := 1
150 col := 0
151 for _, ch := range s[:i] {
152 if ch == '\n' {
153 line++
154 col = 0
155 } else {
156 col++
157 }
158 }
159 return text, line, col
160 }
161 }
162 return s, 1, -1
163}

Callers 1

TestCompletionFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected