@@ -14,43 +14,22 @@ const config = {
1414 vscodeVersionKey : 'data-gradient-theme-vscode-version' ,
1515}
1616
17- /**
18- * 判断vscode版本是否低于指定版本
19- * @param {* } version
20- * @returns
21- */
22- function isVSCodeBelowVersion ( version ) {
23- const vscodeVersion = vscode . version . split ( '-' ) [ 0 ]
24- const vscodeVersionArray = vscodeVersion . split ( '.' )
25- const versionArray = version . split ( '.' )
26- return versionArray . some ( ( item , index ) => vscodeVersionArray [ index ] < item )
27- }
17+ // 插件上下文
18+ let context = null
2819
29- /**
30- * 判断vscode版本是否等于指定版本
31- * @param {* } version
32- * @returns
33- */
34- function isVSCodeEqualsVersion ( version ) {
35- const vscodeVersion = vscode . version . split ( '-' ) [ 0 ]
36- const vscodeVersionArray = vscodeVersion . split ( '.' )
37- const versionArray = version . split ( '.' )
38- return versionArray . every ( ( item , index ) => vscodeVersionArray [ index ] === item )
39- }
40-
41- const isWin = / ^ w i n / . test ( process . platform )
42- const appDir = `${ path . dirname ( vscode . env . appRoot ) } /app/out`
43- const base = appDir + ( isWin ? '\\vs\\code' : '/vs/code' )
44- const electronBase =
45- isVSCodeBelowVersion ( '1.70.0' ) && ! isVSCodeEqualsVersion ( '1.100' )
46- ? 'electron-browser'
47- : 'electron-sandbox'
48- const htmlFileName = isVSCodeEqualsVersion ( '1.94' ) ? 'workbench.esm.html' : 'workbench.html'
49- const htmlFile =
50- base +
51- ( isWin
52- ? '\\' + electronBase + '\\workbench\\' + htmlFileName
53- : '/' + electronBase + '/workbench/' + htmlFileName )
20+ const appDir = require . main ? path . dirname ( require . main . filename ) : globalThis . _VSCODE_FILE_ROOT
21+ const base = path . join ( appDir , 'vs' , 'code' )
22+ let htmlFile = path . join ( base , 'electron-sandbox' , 'workbench' , 'workbench.html' )
23+ // support Cursor IDE
24+ if ( ! fs . existsSync ( htmlFile ) ) {
25+ htmlFile = path . join ( base , 'electron-sandbox' , 'workbench' , 'workbench-apc-extension.html' )
26+ }
27+ if ( ! fs . existsSync ( htmlFile ) ) {
28+ htmlFile = path . join ( base , 'electron-sandbox' , 'workbench' , 'workbench.esm.html' )
29+ }
30+ if ( ! fs . existsSync ( htmlFile ) ) {
31+ htmlFile = path . join ( base , 'electron-browser' , 'workbench' , 'workbench.esm.html' )
32+ }
5433
5534const enableCommonMessage = `VSCode must reload for this change to take effect. Code may display a warning that it is corrupted, this is normal. You can dismiss this message by choosing 'Don't show this again' on the notification.`
5635
@@ -63,9 +42,6 @@ const disableCommand = prefix + '.' + disableName
6342const enableMessage = 'Gradient ' + enableName + 'd. ' + enableCommonMessage
6443const disableMessage = 'Gradient ' + disableName + 'd. ' + enableCommonMessage
6544
66- // 插件上下文
67- let context = null
68-
6945/**
7046 * 获取重置html后的html内容,删除所有插件插入的style和script
7147 * @returns
0 commit comments