@@ -4,7 +4,6 @@ import { defaultJsSupersetLangs } from '@zardoy/vscode-utils/build/langs'
4
4
import { getActiveRegularEditor } from '@zardoy/vscode-utils'
5
5
import { getExtensionSetting , extensionCtx , getExtensionSettingId , getExtensionCommandId } from 'vscode-framework'
6
6
import { pickObj } from '@zardoy/utils'
7
- import throttle from 'lodash.throttle'
8
7
import { PostfixCompletion , TriggerCharacterCommand } from '../typescript/src/ipcTypes'
9
8
import { Configuration } from './configurationType'
10
9
@@ -93,9 +92,6 @@ export const activateTsPlugin = (tsApi: { configurePlugin; onCompletionAccepted
93
92
if ( ! result || ! result . body ) return
94
93
return result . body
95
94
} catch ( err ) {
96
- // if (err instanceof Error && err.message.includes('no-ts-essential-plugin-configuration')) {
97
- // void resendConfig()
98
- // }
99
95
console . error ( err )
100
96
} finally {
101
97
console . timeEnd ( `request ${ command } ` )
@@ -149,61 +145,6 @@ export const activateTsPlugin = (tsApi: { configurePlugin; onCompletionAccepted
149
145
( await sendCommand ( 'nodeAtPosition' , { document, position : offset ? document . positionAt ( offset ) : activeTextEditor . selection . active } ) ) ?? { }
150
146
return data
151
147
} )
152
-
153
- // not removing as we can enable it back in near future
154
- const enableExperimentalPluginRestoration = false
155
-
156
- if ( enableExperimentalPluginRestoration ) {
157
- // https://github.com/zardoy/typescript-vscode-plugins/issues/38
158
-
159
- const checkPluginNeedsConfig = async ( ) => {
160
- const { typescriptEssentialsResponse } = await sendCommand ( 'check-configuration' , {
161
- document : vscode . window . activeTextEditor ! . document ,
162
- position : new vscode . Position ( 0 , 0 ) ,
163
- } )
164
- return ! typescriptEssentialsResponse
165
- }
166
-
167
- const { dispose } = vscode . window . onDidChangeActiveTextEditor ( doInitialCheck )
168
- // eslint-disable-next-line no-inner-declarations
169
- async function doInitialCheck ( ) {
170
- const languageId = vscode . window . activeTextEditor ?. document . languageId
171
- // even we have activationEvents, we need this check
172
- if ( ! languageId || ! defaultJsSupersetLangs . includes ( languageId ) ) return
173
- dispose ( )
174
- await new Promise ( resolve => {
175
- setTimeout ( resolve , 300 )
176
- } )
177
- void checkPluginNeedsConfig ( )
178
- }
179
-
180
- void doInitialCheck ( )
181
-
182
- let reloads = 0
183
- const resendConfig = throttle (
184
- async ( ) => {
185
- reloads ++
186
- if ( reloads > 2 ) {
187
- // avoid spamming
188
- if ( reloads > 3 ) return
189
- void vscode . window . showErrorMessage ( "There is a problem with TypeScript plugin as it can't be configured properly. Try to restart TS" )
190
- return
191
- }
192
-
193
- syncConfig ( )
194
- await new Promise ( resolve => {
195
- setTimeout ( resolve , 100 )
196
- } )
197
- if ( await checkPluginNeedsConfig ( ) ) void resendConfig ( )
198
- else reloads = 0
199
- } ,
200
- 200 ,
201
- {
202
- leading : true ,
203
- trailing : false ,
204
- } ,
205
- )
206
- }
207
148
}
208
149
209
150
export const activate = async ( ) => {
0 commit comments