@@ -6,7 +6,6 @@ export function updateDiagnostics(doc: vscode.TextDocument, declaredVariables: S
66 const diagnostics : vscode . Diagnostic [ ] = [ ] ;
77 const text = doc . getText ( ) ;
88 const lines = text . split ( / \r ? \n / ) ;
9-
109 lines . forEach ( ( line , i ) => {
1110 const lineText = line . trim ( ) ;
1211
@@ -15,6 +14,20 @@ export function updateDiagnostics(doc: vscode.TextDocument, declaredVariables: S
1514 const range = new vscode . Range ( i , line . length - 2 , i , line . length ) ;
1615 diagnostics . push ( new vscode . Diagnostic ( range , "Unexpected ';' at end of line" , vscode . DiagnosticSeverity . Error ) ) ;
1716 }
17+ const trimmedLine = line . trim ( ) ;
18+
19+ // Direct string matching (like Python)
20+ if ( trimmedLine . startsWith ( "} else" ) ||
21+ trimmedLine . startsWith ( "} elif" ) ||
22+ trimmedLine . startsWith ( "} except" ) ||
23+ trimmedLine . startsWith ( "} def" ) ||
24+ trimmedLine . startsWith ( "} class" ) ||
25+ trimmedLine . startsWith ( "} case" ) ) {
26+
27+ const range = new vscode . Range ( i , 0 , i , line . length ) ;
28+ diagnostics . push ( new vscode . Diagnostic ( range , `Misplaced '${ trimmedLine } ' statement.` , vscode . DiagnosticSeverity . Error ) ) ;
29+ }
30+
1831 } ) ;
1932
2033 collection . set ( doc . uri , diagnostics ) ;
0 commit comments