@@ -223,15 +223,15 @@ struct SQLEditorView: NSViewRepresentable {
223223 }
224224 }
225225
226− // A table completion carries its own quotes; absorb a directly
227− // preceding opening quote the user typed (e.g. `FROM "my`) so the
228− // inserted `"name"` replaces it instead of producing `""name"`.
229− if item.kind == .table, wordStart > 0,
230− nsText.character(at: wordStart - 1) == 0x22 {
231− wordStart -= 1
232− // Mirror on the trailing side: if a matching closing quote follows
233− // the word (caret inside an already-quoted `FROM "my|"`), absorb it
234− // too so the inserted `"name"` doesn't leave a dangling `"name""`.
226+ // A table completion carries its own quotes; absorb any double-quote the
227+ // user typed directly around the word so the inserted `"name"` replaces
228+ // it instead of leaving a stray quote. Leading and trailing are handled
229+ // independently: a closing quote can exist without an opening one (e.g.
230+ // `FROM my"`), which would otherwise produce a dangling `"name""`.
231+ if item.kind == .table {
232+ if wordStart > 0, nsText.character(at: wordStart - 1) == 0x22 {
233+ wordStart -= 1
234+ }
235235 if wordEnd < nsText.length, nsText.character(at: wordEnd) == 0x22 {
236236 wordEnd += 1
237237 }