Commit 7b18241
authored
* fix: context menu Format SQL not working due to stale closure capture (#659)
Root cause: formatQuery() passed as onFormatSQL closure captures QueryEditorView
struct by value. After SwiftUI recreates the view, the captured @binding queryText
becomes stale (empty). Toolbar button works because it runs in current render context.
Fix: add fallback in context menu that formats directly via the text view when the
callback closure is stale. Also lazily recreate context menu after destroy().
* fix: root cause fix for stale editor callbacks + 3 formatter bugs (#659)
Coordinator lifecycle:
- Move callback wiring from .onAppear to view body (fresh on every re-render)
- Add revive() method to re-register with EditorEventRouter after tab switch
- Add onFormatSQL = nil to destroy() cleanup
- Add databaseType property to coordinator
- Remove hacky formatSQLInTextView fallback (was hardcoding .mysql dialect)
SQL formatter:
- Fix comment placeholder order: single-pass extraction by source position
- Fix SQL-standard '' escape not handled in string literal regex
- Fix addLineBreaks ignoring uppercaseKeywords option
1 parent 569d962 commit 7b18241
3 files changed
Lines changed: 51 additions & 52 deletions
File tree
- TablePro
- Core/Services/Formatting
- Views/Editor
Lines changed: 17 additions & 35 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
40 | 40 | | |
41 | 41 | | |
42 | 42 | | |
| 43 | + | |
43 | 44 | | |
44 | 45 | | |
45 | 46 | | |
46 | 47 | | |
47 | | - | |
| 48 | + | |
48 | 49 | | |
49 | 50 | | |
50 | 51 | | |
51 | 52 | | |
52 | 53 | | |
53 | | - | |
54 | | - | |
55 | | - | |
56 | | - | |
57 | | - | |
58 | | - | |
59 | | - | |
60 | | - | |
61 | | - | |
62 | | - | |
63 | 54 | | |
64 | 55 | | |
65 | 56 | | |
| |||
207 | 198 | | |
208 | 199 | | |
209 | 200 | | |
210 | | - | |
| 201 | + | |
211 | 202 | | |
212 | 203 | | |
213 | 204 | | |
| |||
288 | 279 | | |
289 | 280 | | |
290 | 281 | | |
291 | | - | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
292 | 289 | | |
293 | 290 | | |
294 | 291 | | |
295 | | - | |
296 | 292 | | |
297 | | - | |
298 | | - | |
| 293 | + | |
299 | 294 | | |
300 | 295 | | |
301 | 296 | | |
302 | | - | |
303 | | - | |
304 | | - | |
305 | | - | |
306 | | - | |
307 | | - | |
308 | | - | |
309 | | - | |
310 | | - | |
311 | 297 | | |
312 | | - | |
313 | | - | |
314 | | - | |
315 | | - | |
316 | | - | |
317 | | - | |
318 | | - | |
| 298 | + | |
| 299 | + | |
319 | 300 | | |
320 | 301 | | |
| 302 | + | |
321 | 303 | | |
322 | | - | |
323 | 304 | | |
324 | 305 | | |
325 | 306 | | |
| |||
363 | 344 | | |
364 | 345 | | |
365 | 346 | | |
366 | | - | |
| 347 | + | |
367 | 348 | | |
368 | 349 | | |
369 | 350 | | |
370 | 351 | | |
| 352 | + | |
371 | 353 | | |
372 | 354 | | |
373 | 355 | | |
374 | | - | |
| 356 | + | |
375 | 357 | | |
376 | 358 | | |
377 | 359 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
50 | 50 | | |
51 | 51 | | |
52 | 52 | | |
| 53 | + | |
53 | 54 | | |
54 | 55 | | |
55 | 56 | | |
| |||
172 | 173 | | |
173 | 174 | | |
174 | 175 | | |
| 176 | + | |
175 | 177 | | |
176 | 178 | | |
177 | 179 | | |
| |||
185 | 187 | | |
186 | 188 | | |
187 | 189 | | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
188 | 201 | | |
189 | 202 | | |
190 | 203 | | |
| |||
212 | 225 | | |
213 | 226 | | |
214 | 227 | | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
215 | 231 | | |
216 | 232 | | |
217 | 233 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
38 | 38 | | |
39 | 39 | | |
40 | 40 | | |
41 | | - | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
42 | 53 | | |
43 | 54 | | |
44 | 55 | | |
| |||
97 | 108 | | |
98 | 109 | | |
99 | 110 | | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
100 | 114 | | |
101 | 115 | | |
102 | 116 | | |
103 | | - | |
104 | | - | |
105 | | - | |
106 | | - | |
107 | | - | |
108 | | - | |
109 | | - | |
110 | | - | |
111 | 117 | | |
112 | 118 | | |
113 | 119 | | |
114 | 120 | | |
115 | 121 | | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
116 | 125 | | |
117 | 126 | | |
118 | 127 | | |
119 | | - | |
120 | | - | |
121 | | - | |
122 | | - | |
123 | | - | |
124 | | - | |
125 | | - | |
126 | | - | |
127 | 128 | | |
128 | 129 | | |
129 | 130 | | |
| |||
0 commit comments