4
4
import { red , yellow , blue } from "ansi-colors" ;
5
5
import * as vscode from "vscode" ;
6
6
import { DebugManager } from "./debugmanager" ;
7
+ import * as fs from "fs" ;
7
8
8
9
import {
9
10
ClientState ,
@@ -142,7 +143,7 @@ export class TestControllerManager {
142
143
private readonly refreshMutex = new Mutex ( ) ;
143
144
private readonly debugSessions = new Set < vscode . DebugSession > ( ) ;
144
145
private readonly didChangedTimer = new Map < string , DidChangeEntry > ( ) ;
145
- private fileChangeTimer : DidChangeEntry | undefined ;
146
+ private refreshWorkspaceChangeTimer : DidChangeEntry | undefined ;
146
147
private diagnosticCollection = vscode . languages . createDiagnosticCollection ( "robotCode discovery" ) ;
147
148
148
149
constructor (
@@ -166,12 +167,17 @@ export class TestControllerManager {
166
167
( _ ) => undefined ,
167
168
) ;
168
169
169
- const fileWatcher = vscode . workspace . createFileSystemWatcher (
170
- `**/*.{${ this . languageClientsManager . fileExtensions . join ( "," ) } }` ,
171
- ) ;
172
- fileWatcher . onDidCreate ( ( uri ) => this . refreshUri ( uri , "create" ) ) ;
173
- fileWatcher . onDidDelete ( ( uri ) => this . refreshUri ( uri , "delete" ) ) ;
174
- fileWatcher . onDidChange ( ( uri ) => this . refreshUri ( uri , "change" ) ) ;
170
+ const fileWatcher = vscode . workspace . createFileSystemWatcher ( `**/[!._]*` ) ;
171
+
172
+ fileWatcher . onDidCreate ( ( uri ) => {
173
+ this . refreshUri ( uri , "create" ) ;
174
+ } ) ;
175
+ fileWatcher . onDidDelete ( ( uri ) => {
176
+ this . refreshUri ( uri , "delete" ) ;
177
+ } ) ;
178
+ fileWatcher . onDidChange ( ( uri ) => {
179
+ this . refreshUri ( uri , "change" ) ;
180
+ } ) ;
175
181
176
182
this . _disposables = vscode . Disposable . from (
177
183
this . diagnosticCollection ,
@@ -730,7 +736,7 @@ export class TestControllerManager {
730
736
731
737
const result = await this . discoverTests (
732
738
folder ,
733
- [ "discover" , "--no-diagnostics" , "-- read-from-stdin", "all" ] ,
739
+ [ "discover" , "--read-from-stdin" , "all" ] ,
734
740
[ ] ,
735
741
JSON . stringify ( o ) ,
736
742
true ,
@@ -792,7 +798,7 @@ export class TestControllerManager {
792
798
793
799
const result = await this . discoverTests (
794
800
folder ,
795
- [ "discover" , "--no-diagnostics" , "-- read-from-stdin", "tests" ] ,
801
+ [ "discover" , "--read-from-stdin" , "tests" ] ,
796
802
[
797
803
...( robotWorkspaceItem ?. needs_parse_include && testItem . rel_source
798
804
? [ "--parse-include" , testItem . rel_source ]
@@ -1023,33 +1029,46 @@ export class TestControllerManager {
1023
1029
}
1024
1030
1025
1031
private refreshUri ( uri ?: vscode . Uri , reason ?: string ) {
1026
- if ( vscode . workspace . textDocuments . find ( ( d ) => d . uri . toString ( ) === uri ?. toString ( ) ) ) return ;
1032
+ if ( uri ) {
1033
+ if ( uri ?. scheme !== "file" ) return ;
1027
1034
1028
- this . outputChannel . appendLine ( `refresh uri ${ uri ? uri . toString ( ) : "unknown" } because: ${ reason ?? "unknown" } ` ) ;
1035
+ const exists = fs . existsSync ( uri . fsPath ) ;
1036
+ const isFileAndExists = exists && fs . statSync ( uri . fsPath ) . isFile ( ) ;
1029
1037
1030
- if ( uri ) {
1031
- const testItem = this . findTestItemByUri ( uri . toString ( ) ) ;
1032
- if ( testItem ) {
1033
- this . refreshItem ( testItem ) . then (
1034
- ( _ ) => undefined ,
1035
- ( _ ) => undefined ,
1036
- ) ;
1038
+ if (
1039
+ isFileAndExists &&
1040
+ ! this . languageClientsManager . fileExtensions . some ( ( ext ) => uri ?. path . toLowerCase ( ) . endsWith ( `.${ ext } ` ) )
1041
+ )
1037
1042
return ;
1043
+
1044
+ if ( isFileAndExists && vscode . workspace . textDocuments . find ( ( d ) => d . uri . toString ( ) === uri ?. toString ( ) ) ) return ;
1045
+
1046
+ this . outputChannel . appendLine ( `refresh uri ${ uri ? uri . toString ( ) : "unknown" } because: ${ reason ?? "unknown" } ` ) ;
1047
+
1048
+ if ( exists ) {
1049
+ const testItem = this . findTestItemByUri ( uri . toString ( ) ) ;
1050
+ if ( testItem ) {
1051
+ this . refreshItem ( testItem ) . then (
1052
+ ( _ ) => undefined ,
1053
+ ( _ ) => undefined ,
1054
+ ) ;
1055
+ return ;
1056
+ }
1038
1057
}
1039
1058
1040
1059
const workspace = vscode . workspace . getWorkspaceFolder ( uri ) ;
1041
1060
if ( workspace === undefined ) return ;
1042
1061
1043
1062
if ( this . didChangedTimer . has ( uri . toString ( ) ) ) return ;
1044
1063
1045
- if ( this . fileChangeTimer ) {
1046
- this . fileChangeTimer . cancel ( ) ;
1047
- this . fileChangeTimer = undefined ;
1064
+ if ( this . refreshWorkspaceChangeTimer ) {
1065
+ this . refreshWorkspaceChangeTimer . cancel ( ) ;
1066
+ this . refreshWorkspaceChangeTimer = undefined ;
1048
1067
}
1049
1068
1050
1069
const cancelationTokenSource = new vscode . CancellationTokenSource ( ) ;
1051
1070
1052
- this . fileChangeTimer = new DidChangeEntry (
1071
+ this . refreshWorkspaceChangeTimer = new DidChangeEntry (
1053
1072
setTimeout ( ( ) => {
1054
1073
this . refreshWorkspace ( workspace , reason , cancelationTokenSource . token ) . then (
1055
1074
( ) => undefined ,
@@ -1059,9 +1078,9 @@ export class TestControllerManager {
1059
1078
cancelationTokenSource ,
1060
1079
) ;
1061
1080
} else {
1062
- if ( this . fileChangeTimer ) {
1063
- this . fileChangeTimer . cancel ( ) ;
1064
- this . fileChangeTimer = undefined ;
1081
+ if ( this . refreshWorkspaceChangeTimer ) {
1082
+ this . refreshWorkspaceChangeTimer . cancel ( ) ;
1083
+ this . refreshWorkspaceChangeTimer = undefined ;
1065
1084
}
1066
1085
1067
1086
this . refresh ( ) . then (
0 commit comments