File tree Expand file tree Collapse file tree 2 files changed +11
-14
lines changed Expand file tree Collapse file tree 2 files changed +11
-14
lines changed Original file line number Diff line number Diff line change 1010> - :house : [ Internal]
1111> - :nail_care : [ Polish]
1212
13+ ## [ Unreleased]
14+
15+ #### :bug : Bug fix
16+
17+ - Only paste objects/arrays are JSON.t https://github.com/rescript-lang/rescript-vscode/pull/1148
18+
1319## 1.68.0
1420
1521#### :rocket : New Feature
Original file line number Diff line number Diff line change @@ -11,20 +11,7 @@ const isLikelyJson = (text: string): boolean => {
1111 return false ;
1212 }
1313 const first = trimmed [ 0 ] ;
14- if ( first === "{" || first === "[" || first === '"' || first === "-" ) {
15- return true ;
16- }
17- if ( first >= "0" && first <= "9" ) {
18- return true ;
19- }
20- if (
21- trimmed . startsWith ( "true" ) ||
22- trimmed . startsWith ( "false" ) ||
23- trimmed . startsWith ( "null" )
24- ) {
25- return true ;
26- }
27- return false ;
14+ return first === "{" || first === "[" ;
2815} ;
2916
3017const ensureFloatString = ( value : number ) : string => {
@@ -99,6 +86,10 @@ export const convertPlainTextToJsonT = (text: string): JsonConversionResult => {
9986
10087 try {
10188 const parsed = JSON . parse ( text ) ;
89+ // Only convert objects and arrays, not primitive values
90+ if ( typeof parsed !== "object" || parsed === null ) {
91+ return { kind : "notJson" } ;
92+ }
10293 return { kind : "success" , formatted : formatJsonValue ( parsed ) } ;
10394 } catch {
10495 return {
You can’t perform that action at this time.
0 commit comments