@@ -68,19 +68,19 @@ export const problemProvider = [
6868
6969 workspace . onDidChangeTextDocument ( e => {
7070 const isSql = e . document . languageId === `sql` ;
71- if ( isSql && checkOnChange ( ) ) {
71+ if ( isSql && checkOnChange ( ) && e . contentChanges . length > 0 ) {
7272 if ( currentTimeout ) {
7373 clearTimeout ( currentTimeout ) ;
7474 }
7575
7676 currentTimeout = setTimeout ( ( ) => {
77- validateSqlDocument ( e . document ) ;
77+ validateSqlDocument ( e . document , e . document . offsetAt ( e . contentChanges [ 0 ] . range . start ) ) ;
7878 } , getCheckerTimeout ( ) ) ;
7979 }
8080 } )
8181] ;
8282
83- async function validateSqlDocument ( document : TextDocument ) {
83+ async function validateSqlDocument ( document : TextDocument , specificStatement ?: number ) {
8484 const checker = SQLStatementChecker . get ( ) ;
8585 if ( remoteAssistIsEnabled ( ) && checker ) {
8686 const content = document . getText ( ) ;
@@ -92,12 +92,23 @@ async function validateSqlDocument(document: TextDocument) {
9292 for ( const group of allGroups ) {
9393 const range = getStatementRangeFromGroup ( group ) ;
9494 if ( range ) {
95+ if ( specificStatement ) {
96+ // If specificStatement is outline this range, continue
97+ if ( specificStatement <= range [ 0 ] || specificStatement >= range [ 1 ] ) {
98+ continue ;
99+ }
100+ }
101+
95102 statementRanges . push ( range ) ;
96103 }
97104 }
98105
99106 const sqlStatementContents = statementRanges . map ( range => content . substring ( range [ 0 ] , range [ 1 ] ) ) ;
107+ const se = performance . now ( ) ;
100108 const syntaxChecked = await checker . checkMultipleStatements ( sqlStatementContents ) ;
109+ const ee = performance . now ( ) ;
110+
111+ console . log ( `Syntax check took: ${ ee - se } ms` ) ;
101112
102113 if ( syntaxChecked ) {
103114 if ( syntaxChecked . length > 0 ) {
0 commit comments