Skip to content

Commit 9be3e41

Browse files
committed
fix possible definition d.ts -> js bug & new code action
1 parent 1a4848e commit 9be3e41

File tree

3 files changed

+9
-3
lines changed

3 files changed

+9
-3
lines changed

buildTsPlugin.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ const result = await buildTsPlugin('typescript', undefined, undefined, {
66
minify: !process.argv.includes('--watch'),
77
metafile: true,
88
define: {
9-
'import.meta': 'null',
9+
'import.meta': '{}',
1010
},
1111
banner: {
1212
js: 'let ts, tsFull;',

src/specialCommands.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import * as vscode from 'vscode'
22
import { getActiveRegularEditor } from '@zardoy/vscode-utils'
3-
import { getExtensionCommandId, registerExtensionCommand, VSCodeQuickPickItem } from 'vscode-framework'
3+
import { getExtensionCommandId, getExtensionSetting, registerExtensionCommand, VSCodeQuickPickItem } from 'vscode-framework'
44
import { showQuickPick } from '@zardoy/vscode-utils/build/quickPick'
55
import _ from 'lodash'
66
import { compact } from '@zardoy/utils'
@@ -271,7 +271,12 @@ export default () => {
271271
// its actually a code action, but will be removed from there soon
272272
vscode.languages.registerCodeActionsProvider(defaultJsSupersetLangsWithVue, {
273273
async provideCodeActions(document, range, context, token) {
274-
if (context.triggerKind !== vscode.CodeActionTriggerKind.Invoke || document !== vscode.window.activeTextEditor?.document) return
274+
if (
275+
context.triggerKind !== vscode.CodeActionTriggerKind.Invoke ||
276+
document !== vscode.window.activeTextEditor?.document ||
277+
!getExtensionSetting('enablePlugin')
278+
)
279+
return
275280
const result = await sendTurnIntoArrayRequest(range)
276281
if (!result) return
277282
const { keysCount, totalCount, totalObjectCount } = result

typescript/src/definitions.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ export default (proxy: ts.LanguageService, info: ts.server.PluginCreateInfo, c:
1919
prior.definitions?.length === 1 &&
2020
// default, namespace import or import path click
2121
firstDef.containerName === '' &&
22+
firstDef.name.slice(1, -1) === firstDef.fileName.slice(0, -'.d.ts'.length) &&
2223
firstDef.fileName.endsWith('.d.ts')
2324
) {
2425
const jsFileName = `${firstDef.fileName.slice(0, -'.d.ts'.length)}.js`

0 commit comments

Comments
 (0)