@@ -256,7 +256,9 @@ export const JsonEditorView = ({
256256 } catch {
257257 /* ignore */
258258 }
259- let skipCommaFix = false ;
259+ // Programmatic edits (config update, comma fix, reformat) set this flag
260+ // so subsequent content-change events from setValue don't re-trigger fixes.
261+ let isProgrammaticEdit = false ;
260262
261263 const applyEditAndReformat = (
262264 edit : { offset : number ; length : number ; newText : string } ,
@@ -267,7 +269,7 @@ export const JsonEditorView = ({
267269 const start = model . getPositionAt ( edit . offset ) ;
268270 const end = model . getPositionAt ( edit . offset + edit . length ) ;
269271 queueMicrotask ( ( ) => {
270- skipCommaFix = true ;
272+ isProgrammaticEdit = true ;
271273 editor . executeEdits ( source , [
272274 {
273275 range : {
@@ -288,6 +290,12 @@ export const JsonEditorView = ({
288290 let commaTimer : number | null = null ;
289291
290292 const disposable = editor . onDidChangeModelContent ( ( ) => {
293+ // Skip all reactive logic for changes we made ourselves
294+ if ( isProgrammaticEdit ) {
295+ isProgrammaticEdit = false ;
296+ return ;
297+ }
298+
291299 const text = editor . getValue ( ) ;
292300
293301 // 1. Debounced hint update
@@ -297,14 +305,11 @@ export const JsonEditorView = ({
297305 // 2. Debounced comma auto-fix
298306 if ( commaTimer ) window . clearTimeout ( commaTimer ) ;
299307 commaTimer = window . setTimeout ( ( ) => {
300- if ( skipCommaFix ) {
301- skipCommaFix = false ;
302- return ;
303- }
304308 if ( isSuggestWidgetVisible ( editor ) ) return ;
305309 const current = editor . getValue ( ) ;
306310 const fixed = fixJsonCommas ( current ) ;
307311 if ( fixed !== current ) {
312+ isProgrammaticEdit = true ;
308313 const pos = editor . getPosition ( ) ;
309314 editor . setValue ( fixed ) ;
310315 if ( pos ) editor . setPosition ( pos ) ;
0 commit comments