File tree Expand file tree Collapse file tree
src/extensions/default/Phoenix-prettier/worker Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -85,7 +85,18 @@ async function prettify(params) {
8585 options . rangeStart = options . rangeStart || 0 ;
8686 options . rangeEnd = options . rangeEnd || params . text . length ;
8787 await _loadPlugin ( options . _usePlugin ) ;
88- let { formatted, cursorOffset} = await prettier . formatWithCursor ( params . text , options ) ;
88+ const pluginName = options . _usePlugin ;
89+ delete options . _usePlugin ;
90+ let formatted , cursorOffset ;
91+ if ( pluginName === "json-stringify" ) {
92+ // json stringify impl of format with cursor has a bug where it will get stuck prettying for like 10 secs
93+ // for some rare files. so we use the original prettier without cursor fn
94+ formatted = await prettier . format ( params . text , options ) ;
95+ } else {
96+ let prettyResult = await prettier . formatWithCursor ( params . text , options ) ;
97+ formatted = prettyResult . formatted ;
98+ cursorOffset = prettyResult . cursorOffset ;
99+ }
89100 if ( isFullFileBeautify ) {
90101 return {
91102 text : formatted ,
You can’t perform that action at this time.
0 commit comments