@@ -68,19 +68,19 @@ export const problemProvider = [
68
68
69
69
workspace . onDidChangeTextDocument ( e => {
70
70
const isSql = e . document . languageId === `sql` ;
71
- if ( isSql && checkOnChange ( ) ) {
71
+ if ( isSql && checkOnChange ( ) && e . contentChanges . length > 0 ) {
72
72
if ( currentTimeout ) {
73
73
clearTimeout ( currentTimeout ) ;
74
74
}
75
75
76
76
currentTimeout = setTimeout ( ( ) => {
77
- validateSqlDocument ( e . document ) ;
77
+ validateSqlDocument ( e . document , e . document . offsetAt ( e . contentChanges [ 0 ] . range . start ) ) ;
78
78
} , getCheckerTimeout ( ) ) ;
79
79
}
80
80
} )
81
81
] ;
82
82
83
- async function validateSqlDocument ( document : TextDocument ) {
83
+ async function validateSqlDocument ( document : TextDocument , specificStatement ?: number ) {
84
84
const checker = SQLStatementChecker . get ( ) ;
85
85
if ( remoteAssistIsEnabled ( ) && checker ) {
86
86
const content = document . getText ( ) ;
@@ -92,12 +92,23 @@ async function validateSqlDocument(document: TextDocument) {
92
92
for ( const group of allGroups ) {
93
93
const range = getStatementRangeFromGroup ( group ) ;
94
94
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
+
95
102
statementRanges . push ( range ) ;
96
103
}
97
104
}
98
105
99
106
const sqlStatementContents = statementRanges . map ( range => content . substring ( range [ 0 ] , range [ 1 ] ) ) ;
107
+ const se = performance . now ( ) ;
100
108
const syntaxChecked = await checker . checkMultipleStatements ( sqlStatementContents ) ;
109
+ const ee = performance . now ( ) ;
110
+
111
+ console . log ( `Syntax check took: ${ ee - se } ms` ) ;
101
112
102
113
if ( syntaxChecked ) {
103
114
if ( syntaxChecked . length > 0 ) {
0 commit comments