Skip to content

Commit 20e2856

Browse files
authored
Merge pull request #103 from zardoy/develop
2 parents 3a25f12 + cf8e348 commit 20e2856

28 files changed

+551
-153
lines changed

.github/workflows/release.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,3 +32,5 @@ jobs:
3232
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
3333
VSCE_PAT: ${{ secrets.VSCE_PAT }}
3434
OVSX_PAT: ${{ secrets.OVSX_PAT }}
35+
# optional
36+
EXTENSION_ICON: ${{ secrets.EXTENSION_ICON }}

.vscode/settings.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,13 @@
11
{
2+
"tsEssentialPlugins.autoImport.changeToNamespaceImport": {
3+
"typescript": {
4+
"namespace": "ts",
5+
"addImport": false
6+
}
7+
},
8+
"tsEssentialPlugins.suggestions.ignoreAutoImports": [
9+
"typescript-full"
10+
],
211
"betterSnippets.customSnippets": [
312
{
413
"name": "SyntaxKind",

README.MD

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,21 @@
11
# TypeScript Essential Plugins
22

3+
Feature-complete TypeScript plugin that improves every single builtin feature such as completions, definitions, references and so on, and also adds even new TypeScript killer features, so you can work with large codebases faster!
4+
We make completions more informative. Definitions, references (and sometimes even completions) less noisy. And finally our main goal is to provide most customizable TypeScript experience for IDE features.
5+
6+
TOC:
7+
8+
- [Top Features](#top-features)
9+
- [Minor Useful Features](#minor-useful-features)
10+
- [Auto Imports](#auto-imports)
11+
- [Rename Features](#rename-features)
12+
- [Special Commands List](#special-commands-list)
13+
- [Contributed Code Actions](#contributed-code-actions)
14+
- [Even Even More](#even-even-more)
15+
316
## Top Features
417

5-
> Here React experience hits different!
18+
> Note: With this plugin React experience hits different! (see below)
619
720
### Special Commands & Actions
821

@@ -364,4 +377,4 @@ const a = {
364377

365378
## Even Even More
366379

367-
Please look at extension settings, as this extension has much more features than described here!
380+
Also please take a look at extension settings, as this extension has much more features than described here!

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@
116116
"esbuild": "^0.16.16",
117117
"fs-extra": "^10.1.0",
118118
"got": "^12.5.3",
119+
"got-cjs": "npm:got@^11.x",
119120
"type-fest": "^2.13.1",
120121
"typed-jsonfile": "^0.2.1",
121122
"typescript": "^4.9.3",

pnpm-lock.yaml

Lines changed: 115 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/apiCommands.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { sendCommand } from './sendCommand'
66
export default () => {
77
/** @unique */
88
const cacheableCommands: Set<(typeof passthroughExposedApiCommands)[number]> = new Set(['getNodePath', 'getSpanOfEnclosingComment', 'getNodeAtPosition'])
9-
const operationsCache = new Map<string, { key: string; data }>()
9+
const operationsCache = new Map<string, { key: string; data; time?: number }>()
1010
const sharedRequest = async (type: TriggerCharacterCommand, { offset, relativeOffset = 0, document, position }: RequestOptions) => {
1111
if (position && offset) throw new Error('Only position or offset parameter can be provided')
1212
if (document && !offset && !position) throw new Error('When custom document is provided, offset or position must be provided')
@@ -18,10 +18,11 @@ export default () => {
1818
const requestOffset = offset ?? document.offsetAt(position!)
1919
const requestPos = position ?? document.positionAt(offset!)
2020
const getData = async () => sendCommand(type, { document: document!, position: requestPos })
21+
const CACHE_UNDEFINED_TIMEOUT = 1000
2122
if (cacheableCommands.has(type as any)) {
2223
const cacheEntry = operationsCache.get(type)
2324
const operationKey = `${document.uri.toString()}:${document.version}:${requestOffset}`
24-
if (cacheEntry?.key === operationKey) {
25+
if (cacheEntry?.key === operationKey && cacheEntry?.time && Date.now() - cacheEntry.time < CACHE_UNDEFINED_TIMEOUT) {
2526
return cacheEntry.data
2627
}
2728

@@ -31,9 +32,9 @@ export default () => {
3132
// at the same time:
3233
// extension 2 completion provider requests API data at the same document and position
3334
// and so on
34-
operationsCache.set(type, { key: operationKey, data })
35+
operationsCache.set(type, { key: operationKey, data, time: data === undefined ? Date.now() : undefined })
3536
if (type === 'getNodePath') {
36-
operationsCache.set('getNodeAtPosition', { key: operationKey, data: data.then((path: any) => path[path.length - 1]) })
37+
operationsCache.set('getNodeAtPosition', { key: operationKey, data: data.then((path: any) => path?.[path.length - 1]) })
3738
}
3839

3940
return data

0 commit comments

Comments
 (0)