Skip to content

Commit 67e5e8b

Browse files
committed
fixes #48
1 parent 23226ae commit 67e5e8b

File tree

3 files changed

+1
-66
lines changed

3 files changed

+1
-66
lines changed

src/extension.ts

Lines changed: 0 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import { defaultJsSupersetLangs } from '@zardoy/vscode-utils/build/langs'
44
import { getActiveRegularEditor } from '@zardoy/vscode-utils'
55
import { getExtensionSetting, extensionCtx, getExtensionSettingId, getExtensionCommandId } from 'vscode-framework'
66
import { pickObj } from '@zardoy/utils'
7-
import throttle from 'lodash.throttle'
87
import { PostfixCompletion, TriggerCharacterCommand } from '../typescript/src/ipcTypes'
98
import { 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

209150
export const activate = async () => {

typescript/src/ipcTypes.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
export const triggerCharacterCommands = ['find-in-import', 'getPostfixes', 'nodeAtPosition', 'check-configuration'] as const
1+
export const triggerCharacterCommands = ['find-in-import', 'getPostfixes', 'nodeAtPosition'] as const
22
export type TriggerCharacterCommand = typeof triggerCharacterCommands[number]
33

44
export type NodeAtPositionResponse = {

typescript/src/specialCommands/handle.ts

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,6 @@ export default (
1313
entries: []
1414
typescriptEssentialsResponse: any
1515
} => {
16-
if (specialCommand === 'check-configuration') {
17-
return {
18-
entries: [],
19-
typescriptEssentialsResponse: !!configuration,
20-
}
21-
}
2216
if (triggerCharacterCommands.includes(specialCommand) && !configuration) {
2317
throw new Error('no-ts-essential-plugin-configuration')
2418
}

0 commit comments

Comments
 (0)