@@ -32,7 +32,6 @@ export function outputConsole(data: string[]): void {
32
32
}
33
33
34
34
import { InputBoxManager } from "./inputBoxManager" ;
35
- import { getCategory } from "../commands/export" ;
36
35
export { InputBoxManager } ;
37
36
38
37
// tslint:disable-next-line: interface-name
@@ -62,16 +61,9 @@ export interface ConnectionTarget {
62
61
* @param workspace The workspace the file is in.
63
62
*/
64
63
function getServerDocName ( localPath : string , workspace : string ) : string {
65
- let result = localPath ;
66
64
const workspacePath = workspaceFolderUri ( workspace ) . fsPath ;
67
- result = result . replace ( workspacePath + path . sep , "" ) ;
68
- const { folder, addCategory } = config ( "export" , workspace ) ;
69
- result = result . replace ( folder + path . sep , "" ) ;
70
- const cat = addCategory ? getCategory ( localPath , addCategory ) : null ;
71
- if ( cat !== null ) {
72
- result = result . replace ( cat + path . sep , "" ) ;
73
- }
74
- return result . replace ( path . sep , "/" ) ;
65
+ const filePathNoWorkspaceArr = localPath . replace ( workspacePath + path . sep , "" ) . split ( path . sep ) ;
66
+ return filePathNoWorkspaceArr . slice ( filePathNoWorkspaceArr . indexOf ( "csp" ) ) . join ( "/" ) ;
75
67
}
76
68
77
69
/**
@@ -80,18 +72,10 @@ function getServerDocName(localPath: string, workspace: string): string {
80
72
* @param file The file to check.
81
73
*/
82
74
export function isImportableLocalFile ( file : vscode . TextDocument ) : boolean {
83
- let result = false ;
84
75
const workspace = currentWorkspaceFolder ( file ) ;
85
76
const workspacePath = workspaceFolderUri ( workspace ) . fsPath ;
86
- const { folder, addCategory } = config ( "export" , workspace ) ;
87
77
const filePathNoWorkspaceArr = file . fileName . replace ( workspacePath + path . sep , "" ) . split ( path . sep ) ;
88
- const cat = addCategory ? getCategory ( file . fileName , addCategory ) : null ;
89
- if ( filePathNoWorkspaceArr [ 0 ] === folder ) {
90
- if ( cat === null || ( cat !== null && filePathNoWorkspaceArr [ 1 ] === cat ) ) {
91
- result = true ;
92
- }
93
- }
94
- return result ;
78
+ return filePathNoWorkspaceArr . includes ( "csp" ) ;
95
79
}
96
80
97
81
export function currentFile ( document ?: vscode . TextDocument ) : CurrentFile {
@@ -142,6 +126,10 @@ export function currentFile(document?: vscode.TextDocument): CurrentFile {
142
126
}
143
127
} else {
144
128
if ( document . uri . scheme === "file" ) {
129
+ if ( fileExt . match ( / ( c s p | c s r ) / i) && ! isImportableLocalFile ( document ) ) {
130
+ // This is a csp or csr file that's not in a csp directory
131
+ return null ;
132
+ }
145
133
name = getServerDocName ( fileName , currentWorkspaceFolder ( document ) ) ;
146
134
} else {
147
135
name = fileName ;
0 commit comments