Skip to content

VSCode Formatted wrong TextDocument #266688

@RedCMD

Description

@RedCMD

Not sure exactly how I did it
but I managed to initiate a format on one document
and have it execute on another

it all happened so quickly
I believe I attempted to format the yaml-1.1.tmLanguage.json file
then I think I quickly switched to the package.json file
and all the formatting edits were applied to the package.json file instead of the yaml...json file

Image

Resulting in this mess
Image
Image

Broken `package.json` file https://github.com/RedCMD/TmLanguage-Syntax-Highlighter/blob/main/package.json
{
	"name": "tmlanguage-syntax-hig: [
		displayName": "TextMate Syntax Highlighting and Intellisense",,
		description": "Syntax Highlighting and Intellisense for VSCodes's JSON based TextMate grammars",,
		publisher": "RedCMD",
	],
	"engines": {,
		"vsco: ": "^1.87.,
	},: ,
	"icon": ": sets/TextMate-logo-icon.png",,
	"repositor: [
		{ ype": "gi: , }
	],
	},: {
		bugs": {: {
			url": "htt: [
				{
					epage": ": tps://marketplace.visualstudio.com/items?itemName=RedCMD.tmlanguage-synt,
					leryBan: r": {,
					lor": ": 43A,
					eme": : ark",
					: [
						{ ds": [:  },
						{ ate",:  },
						{ guage",:  },
						{ mate",:  }
					]
				},
				{
					: ,
					egories:  [,
					ogrammi:  Lang,
					ippets: ,
					rmatters": [
						: {  },
						{ lities": :  },
						{ alWorkspa: s": { },
						{ orted": t: e, }
					]
				}
			]
		},
			"description": : {
			"restrict: Configurations": [],
			: ,
			: ,
			xtensi: Dependencies": ,
			vscode.jso: [
				{
					ivationEv: ts": [],,
					n": "./: t/extension.js",,
					wser": "./out/web/extension.,
					ipts": {: {
						ld": { pm run: ompile && npm run compile-web && npm run gene },
						kag: { "vsce : ckage --follow-symlinks", },
						lis: { "vsce : blish --follow-symlinks", },
						ch": { sc -wa: h -p ./", }
					},
					mpile": "tsc -p ./",,
					mpile-web": [
						{ ate-wasm": "cd ./src/tree-sitte },
						{ : "vscode: mgrammar-snap },
						{ e-test": : pm run test -- --updat }
					]
				},
				{ ributes"::  }
			]
		},
				"id": "jso: {
				"aliases:  [,
					"JSON Te: [
				{ :  },
				{ xtensions:  [ },
				{ .tmLangua: .json", },
				{ .JSON-tmL: guage", },
				{
					,: ,
					filenam: ": [,
					"tmLan: age.json",
					,: [
						{
							*/syntaxe: *.tmLanguage.json",,
							*/synta: s/*.tmLanguage copy{, [0-9]*}.json",,
							*/syn: xes,
							: ,
							rstLine": "{(\": {
								fig: { ion": : /language-configuration.json", },
								n":: : {  },
								rk": { ssets/: xtMate-file-icon.svg", },
								ght: { assets: extMate-file-icon.svg" },
								: : {  },
								: : {  },
								: 
							},
							iases": [: [
								{
									: ,
									nsions": [,
									Langu: e.json.regex",
									: : {  }: {  },
									iguration": ": language-configurations/regex.,
									": {: [
										{
											": "ass: s/TextMate-file-i,
											: 
										},
										{
											yaml-te: mate",,
											s": [: 
										},
										{
											ions": : ,
											nguage: aml",
										},
										{ tmLanguag:  },
										{
											uration:  "./language-configurations/yaml.language-configu,
											 {: 
										}
									]
								},
								: {  }
							]
						},
						{
							SCII PLIS: TextMate",
							: ,
							tensi: s":,
							textmate",: {
								mLa: { ge",:  },
								mLa: { ge.pli: ", }
							},
							property-l: [
								{
									: ,
									tLine": "^: {
										gur: { n": ".: anguage-configurations/plist.language-c },
										: {: : {  }
									}
								},
								{
									: ,
									: {
										"xm: { :  },
										sio: {  [:  }
									}
								},
								{ st":  }
							]
						},
						{
							": "tex: ate-scopes",,
							iases": [
						},
						: {  }
					]
				}
			]
		},
					"*_scopes.txt": {
				],: [
				{
					icon": : ,
					"dark": "assets/TextMate-file-icon.svg",
				},
				{
					: ,
					: ,
					id": "tmgrammar: {
						lia: { : [:  },
						Tex: { e Snap: rammar-Test" }
					},
					extens: ns": [,
					".snap",: [
						{
							: ,
							nfiguratio: {
								n":: : {  },
								rk": { ssets/: xtMate-file-icon.svg", }
							}
						},
						: {  }
					]
				}
			]
		},
				"scopeNa: {
				"path": : /syntaxes/json.tmLanguage.json",,
				"embedded: [
				{
					,: ,
					unbalan: dBracketScopes": [,
					"invalid.illega: { pec: { dictio: ry-separator.json", } },
					"inval: .illegal.expected-ar,
					"invalid.i: [ { .expected: alue-separato } ]
				},
				{
					: ,
					languag: : "json-textmate-regex",,
					scopeName": [
						{
							: ,
							: ,
							nguage": "yaml-: { mat: { :  } },
							opeName": : [ { e.yaml.te: mate", } ]
						},
						{ eddedLang: ges": { },
						{ ta.embedd: .json.textmate.regexp" }
					]
				},
				{
					"invali: illegal",,
					"storag: type.tag.shorthand.yaml",,
					"keywo: .control.flow",
					: {  }: [  ]
				}
			]
		},
				"path": ".: {
			},: [
				: {  },
				{ anguage":: ascii-textmate", },
				{ copeName": "source.plist.a },
				{ ath": "./: ntaxes/plist-ascii },
				{ mbeddedLa: uages": { },
				{ meta.embe: ed.json. },
				{
					: ,
					: ,
					scopeName": [
						{
							: ,
							: ,
							opeName": : [ { e.plist.a: ii.textmate.scopes", } ]
						},
						: {  },
						: {  }
					]
				},
				{
					balance: racketS,
					"repl: e.c,
					: [
						: {  },
						: {  }
					]
				},
				{
					: ,
					: ,
					scopeName": [
						{ h": "./sy: axes/markdown.tm },
						{ ectTo": [:  }
					]
				},
				{ mbeddedLa: uages": { },
				{ meta.embe: ed.block.json.textmate }
			]
		},
			},: {
			{: ,
				"scope: me": "text.searchResult.json.textmate",,
				"path": "./syntaxes/searchResult.tmLanguage.json",,
				"injectTo": [: {
					"t: { search: sult" },
				],: : {  },
				"em: {
					"meta.emb: ded.json.textmate": "json-textmate",,
					"meta.embe: [
						: {  },
						: {  },
						: {  },
						{ ets": [:  }
					]
				}
			},
			},: {
				: : {  },
				"la: {
					path": ".: nippets/textmate-scopes.code-snippets",
					: [
						: {  },
						{ gurationD: aults": { },
						{ n-textmat: ": { },
						{ tor.maxTo: nizationLineLength": 6 }
					]
				},
				"ed: { .quick: ggestions": { },
					"s: { gs": ": ", },
					"o: { ": "on:  }
			},
				"edit: .inlineSuggest.synt,
				"editor.d: [
				{ ditor.com: nts.insertSpace": false },
				{ ditor.wra: nEscapedLineFeeds": true },
				{ :  },
				{ son-textm: e-regex]": { },
				{ ditor.sni: etSuggestions": "t },
				{ ditor.sug: st.insertMode": },
				{ ditor.sug: st.snippetsPreve },
				{ ditor.sug: st.preview": true, }
			]
		},
					"strings": "i: {
					"other": "inline",,
					"comm: ts": "off",
				},: ,
				"editor.inline: {
				"ed: { .inlin: uggest.enabled": true, },
				"ed: { .wrapO: scapedLineFeeds": true }
			},
			"[yaml-textmate: {
				"ed: { .tabSi: ": 2, },
				"ed: { .inser: paces": true, },
				"ed: { .quick: ggestions": { },
					"s: { gs": ": line", }
			},
					"com: nts": "off",
				}: {  }: [  ]
		},
			"[textmate-scopes]": {: {
				"editor.: ippetSuggestions": "top",,
				"edito: suggest.insertMode": "replace",,
				"edito: quickSuggestions": {,
					"strings": "i: {
					"o: { ": "in: ne", },
					"c: { nts": : nline" },
				}: : {  }
			},
			"[tmgrammar-tes: {
				"ed: { .tabSi: ": 1 },
				: : {  },
				: : {  },
				onf: { ation": [ }
			},
				"titl: : "JSON TextMate",,
				"properti: [
				{ json.text: te.formatting },
				{ "type": ": ring", },
				{ "enum": [:  },
				{ 	"tight",:  },
				{ 	"default:  }
			]
		},
							"Leave no space b: {
							"Sepa: te brackets with a space",
						],: ,
						"d: ault,
						"scope": "re: { ce": : {  } },
					},: : {  }: {  },
					"jso: textmate.sortOrder": {,
						"markdo: [
				{
						"items:  {,
							"typ: : "string",
				},
				{
						"defau: ": [,
							"ver: on",
				},
				{ 	"match",:  }
			]
		},
							"captures",: {
							"begi: aptures",,
							"en: aptures",,
							": ileCaptures",,
							"n: e",,
							"conte: [
				{ 	"scopeNa: ", },
				{
							"firs: ineMatch",,
							"folding: {
							"f: { ngStop: rker", },
							"i: { tionSe: ctor", }
					}
				},
				{
							"patt: ns",,
							"rep: itory",
				},
				{
						"scope:  "resource",
					}: 
				},
				{
					: ,
					onLang: geParticipants": [
				},
				{ anguageId:  "json-textmate" }
			]
		},
		"yamlLanguagePart: {
			{: ,
				"la: uageId": "yaml-textmate",
			}: ,
			,: ,
			jsonValidation": { : : {  } },
			{: ,
				"fileMatc: [ { :  } ]
		},
					"*.tmGramma: {
					"*.JSON: mLanguage",
				],: [
				{
					: ,
					: ,
					mlValid: ion": [,
					: {
						ile: { h": [:  },
						*.t: { guage.: ml", },
						*.t: { guage.: l", },
						*.Y: { tmLang: ge", }
					},
					,: {
						rl": { /vscod: tmLanguage.schema.json" },
						: : {  }
					},
					ewsCon: iners": {,
					ctivitybar: [
						{
							d": "Te: Mat,
							itle": : extMa,
							con": "assets: extMate-file-icon.svg",
							: {  }: [  ]
						},
						{
							s": {: ,
							tMate:  [,
							: {  }: [  ]
						}
					]
				},
				{
					"vis: ility": "visible",,
					"initia: ize": 10,
					,: ,
					: {
						id": { extMat: , },
						nam: { "Call : ack", },
						con: { ualTit: ": "TextMate Call Stack", }
					},
					"visib: ity": "visible",
					: [
						{
							: ,
							s": {: ,
							tor/con: xt": ,
							: [
								{
									up": "0_n: igation@9",
									: ,
									: ,
									title":: ,
									: {
										and: { textma: .refresh", },
										p":: { vigati: @0", },
										": : { w == T: tMate" }
									},
									: ,
									mand": "te: [ { .tree-vie: , } ]
								},
								{
									: ,
									: [
										and": "textmate.list-vie,
										p": "navigation@2",,
										": "view == TextMate && textmate.call.view != 'list'",
										
									],
									mand": : extmate.find",,
									up": : avigation@4",,
									n": "view : [
										{
											: ,
											nd": "e: tor.action,
											": "nav: ation@6",,
											: "view ==: {
												: : {  },
												: : {  },
												d":: { xtmate: ree-view", }
											},
											: "view == Te: Mate",
											: {  }: [  ]
										}
									]
								},
								{
									: ,
									: ,
									mand": : extma,
									up": "conf: [ { :  } ]
								}
							]
						},
						{
							: ,
							ommand": "text,
							roup": "in,
							hen": "vie: [ { extMate &: viewItem == document" } ]
						}
					]
				}
			]
		},
				},: {
				{: ,
					"comm: d": "textmate.goto.file",,
					"grou: : "in,
					"when": : [
				{
					: ,
					"comm: d": "textmate.goto.gra,
					"group:  "inline@7",,
					"when": "v: [
						: {  },
						{
							ommand": "textmate.copyto,
							roup":: 0_navigation@3",
						},
						{
							: ,
							ommand:  "textmate.goto.file",
						},
						{
							: ,
							: 
						},
						{
							hen": ": ew == TextM,
							: 
						},
						: {  }
					]
				},
				{
					title":: Show Text,
					shortTi: e": ",
					category":: [ { Mate",:  } ]
				}
			]
		},
				"command": {
				"title":: Refresh",,
				"category: [
				{
					: ,
					: ,
					command": : [
						{
							tegory": "TextMate,
							on": : ssets/TextMate,
							: {  }: [  ]
						},
						{ mand": "t: tmate.copytocli },
						{ le": "Cop: <grammar state>  }
					]
				},
				{ :  },
				: {  },
				{ ommand": : extmate. },
				{
					categor: : "TextMat,
					icon": "$(link-extern,
					: [
						{
							mmand":: textmate.,
							tle":: Go To File",,
							tegory": ": [ { te",:  } ]
						},
						: {  },
						: {  }
					]
				},
				{ ategory":: TextMate", },
				{ con": "$(: ferences)" }
			]
		},
				"command": ": {
				"title":: View as List",,
				"categ: y":,
				"ico: : ",
			},: : {  }: {  },
			{: : {  }: {  },
				"comm: d": "textmate.tree-view",
				"title": : [
				{
					icon": "$: ist-flat)",
					: ,
					: ,
					command": "text: { .fi: { :  } },
					title": "F: [
						{
							on": "$: earch,
							: 
						},
						{ mand": "e: tor.action.inspectTMSc }
					]
				},
				{ con": "$(: spect)" },
				{ :  },
				: {  },
				{ ommand": : xtension.con }
			]
		},
				"icon": "asse: {
			},: ,
			{: ,
				"com: nd",
				"title": "Conv: { fil: {  YAML":  } },
				"category": : { tMa: { :  } },
				"icon:  "assets/TextMate-file-ic,
			},: [
				{
					command":: extension.convertFileToXML",,
					title":: Convert file to XML",,
					categ: y": "TextMate",,
					icon": "assets/: { Mat: { le-ico: svg" } },
					: [
						{
							mmand":: exten,
							tle": : onvert file to PLIST (ascii)",
						},
						{ n": "asse: /TextMate-file-icon.sv }
					]
				},
				{ ommand": : xtension.convertFileToCS },
				{ itle": "C: vert file to CSON", },
				{ ategory":: TextMate", },
				{ con": "as: ts/TextMate- }
			]
		},
		]: {
			: ,
			ependencie: [
				{
					on-pars: ": "^4.0.9",,
					te-an: time": "^3.6.0",,
					iguruma-parser-: { : ": { .1",:  } },
					igurum: to-es": "^4.3.3",,
					ist": "^3.: [
						{ e-onigmo": "^2.0.1", },
						{ e-oniguru: ": "1.7.0", },
						{ ree-sitte: : "file:node_modules_l },
						{ : "^2.8.0:  }
					]
				},
				{
					ypes/plis: : "^3.0.5",,
					ypes/vs: de": "^1.87.0",,
					scode: est-web": "^0.0.7,
					scode/: ce": "^3.6.0",,
					th-browser: [
						{ sitter-cl: : "^0.25.8", },
						{
							script": "^5.8.3",,
							de-tmg: mmar-test": "file:node_modules_linke
						},
						{ ck-cli": : 6.0.1" },
						: {  }
					]
				},
				{
					blisherDi: layName": "RedCMD",,
					stalled: mestamp": ,
					: ,
					: ,
					: {  }: {  }: {  }: {  }: [
						,
						,
						,
						
					]
				}
			]
		}: : : : : {  }: {  }: : {  }: {  }: {  }: {  }: [
						,
						,
						,
						
					]{
					,
					,
					,
					,
					
				}: : : : : {  }: : {
							,
							
						}: {  }: {  }: [
						,
						,
						,
						
					]{
					,
					,
					,
					,
					
				}: : : : : {  }: {  }: {  }: {  }: [
						,
						,
						,
						
					]{
					,
					,
					,
					,
					
				}: [
				,
				,
				
			]: {
			,
			
		}: : : : : {  }: {  }: : {  }: [  ]: {
			,
			,
			,
			,
			,
			
		}: : : : : {  }: {  }: : {  }: [  ]: {
			,
			,
			,
			,
			,
			
		}: : : : : {  }: : {
					,
					
				}: : {
					,
					
				}: : {
					,
					
				}: : {
					,
					
				}: {  }: [
				,
				,
				,
				,
				,
				
			]: {
			,
			,
			,
			,
			
		}: : : : : {  }: : {
					,
					
				}: : {
					,
					
				}: : {
					,
					
				}: {  }: [
				,
				,
				,
				,
				
			]: {
			,
			,
			,
			,
			
		}: : : : : {  }: : {
					,
					
				}: {  }: [
				,
				,
				
			]: {
			,
			,
			,
			,
			
		}: : : : : {  }: {  }: : {  }: {  }: : : {
					,
					
				}: {  }: [
				,
				
			]: {
			,
			,
			,
			,
			,
			,
			
		}: : : : : {  }: {  }: : {  }: {  }: : : {
					,
					
				}: : {
					,
					
				}: : {
					,
					
				}: {  }: [
				,
				,
				,
				
			]: {
			,
			,
			,
			,
			,
			,
			
		}: : : : : {  }: {  }: : {  }: {  }: : : {
					,
					
				}: : {
					,
					
				}: : {
					,
					
				}: : {
					,
					
				}: [
				,
				,
				,
				
			]: {
			,
			,
			,
			,
			,
			,
			
		}: : : {
					,
					
				}: : {
					,
					
				}: : {
					,
					
				}: : {
					,
					
				}: : {
					,
					
				}: [
				,
				,
				,
				,
				
			]: {
			,
			
		}: : : {
					,
					
				}: : {
					,
					
				}: : {
					,
					
				}: : {
					,
					
				}: : {
					,
					
				}: : {
					,
					
				}: : {
					,
					
				}: : {
					,
					
				}: [
				,
				,
				,
				,
				,
				,
				,
				
			]: {
			,
			
		}: : : {
					,
					
				}: : {
					,
					
				}: : {
					,
					
				}: : {
					,
					
				}: : {
					,
					
				}: : {
					,
					
				}: : {
					,
					
				}: : {
					,
					
				}: [
				,
				,
				,
				,
				,
				,
				,
				
			]: {
			,
			
		}: : [
				,
				,
				,
				,
				,
				,
				
			]: : {
					,
					
				}: : : : : {  }: {  }: : {  }: {  }: : : {
							,
							
						}: : {
							,
							
						}: {  }: : {
							,
							
						}: [
						,
						,
						,
						
					]{
					,
					,
					,
					,
					,
					,
					
				}: : : : : : : {
							,
							,
							
						}: : : : {  }: : {  }: {
								,
								
							}{
							,
							,
							
						}: : : {
							,
							,
							
						}: : {
							,
							
						}: : {
							,
							
						}: {  }: : {
							,
							
						}: [
						,
						,
						,
						,
						,
						,
						
					]{
					,
					,
					,
					,
					
				}: [
				,
				,
				
			]: {
			,
			,
			
		}: : : {  }: : {  }: : {  }: : {  }: {
				,
				,
				,
				
			}: {
			,
			
		}: : : : {  }: : {  }: : {  }: : {  }: {
				,
				,
				,
				
			}: {  }: [  ]: {
			,
			,
			,
			
		}: : : : {
			,
			,
			
		}: : {
					,
					
				}: {  }: {  }: {  }: [
				,
				,
				,
				
			]: {
			
		}: : : : : {  }: {  }: : {  }: [  ]: {
			,
			,
			,
			,
			,
			
		}: : : {
			,
			
		},
		,
		,
		,
		,
		,
		,
		,
		,
		,
		,
		,
		,
		,
		,
		,
		,
		,
		,
		
	}
}

The formatter for the yaml...json file is explicitly set for json-textmate or syntaxes files only
https://github.com/RedCMD/TmLanguage-Syntax-Highlighter/blob/9fdf82d60e62bc848e9a5a1cca6400bd97f562a0/src/extension.ts#L30-L36

Steps to Reproduce:
haven't reproduced it

  1. Format one document
  2. quickly switch to another??
  • VS Code Version: 1.104.0
  • OS Version: Windows 11

Metadata

Metadata

Assignees

Labels

insiders-releasedPatch has been released in VS Code Insiders

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions