@@ -4,7 +4,6 @@ import { defaultJsSupersetLangs } from '@zardoy/vscode-utils/build/langs'
44import { getActiveRegularEditor } from '@zardoy/vscode-utils'
55import { getExtensionSetting , extensionCtx , getExtensionSettingId , getExtensionCommandId } from 'vscode-framework'
66import { pickObj } from '@zardoy/utils'
7- import throttle from 'lodash.throttle'
87import { PostfixCompletion , TriggerCharacterCommand } from '../typescript/src/ipcTypes'
98import { Configuration } from './configurationType'
109
@@ -93,9 +92,6 @@ export const activateTsPlugin = (tsApi: { configurePlugin; onCompletionAccepted
9392 if ( ! result || ! result . body ) return
9493 return result . body
9594 } catch ( err ) {
96- // if (err instanceof Error && err.message.includes('no-ts-essential-plugin-configuration')) {
97- // void resendConfig()
98- // }
9995 console . error ( err )
10096 } finally {
10197 console . timeEnd ( `request ${ command } ` )
@@ -149,61 +145,6 @@ export const activateTsPlugin = (tsApi: { configurePlugin; onCompletionAccepted
149145 ( await sendCommand ( 'nodeAtPosition' , { document, position : offset ? document . positionAt ( offset ) : activeTextEditor . selection . active } ) ) ?? { }
150146 return data
151147 } )
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- }
207148}
208149
209150export const activate = async ( ) => {
0 commit comments