ipatalas / vscode-postfix-ts

Postfix notation for TypeScript/Javascript - extension for VS Code
MIT License
158 stars 43 forks source link

Need to open the js or ts file before the suffix completion is loaded on other files #116

Closed Cattle0Horse closed 6 months ago

Cattle0Horse commented 7 months ago

After re-opening vscode, you must open the .js or .ts file before loading suffix completion. If you do not open the .js or .ts file, other files (such as c++) will not display suffix completion

ipatalas commented 7 months ago

I assume you have extended postfix.languages setting with c++ and others in order to use the extension there as well? This is a limitation of VSCode API. I can activate the extension based on fixed set of file types but this list cannot be dynamic and changed at runtime (makes sense because extensions would have to start first to modify it).

Currently the list is defined as this: https://github.com/ipatalas/vscode-postfix-ts/blob/dc2d17be5f371e20ab8d3b1a535522a45aadddd0/package.json#L24-L30 This makes most sense because those are common types which can contain TS/JS code.

Activating extensions all the time (for all files) is discouraged and I'd rather avoid that as this brings some other potential problems. One solution which I currently see is to also activate the extension when a certain file is present in your workspace. For instance this could be a file like .enable-postfix and when it's present extension will always start no matter which file is open when VSCode launches. Would that be helpful?

Cattle0Horse commented 7 months ago

I assume you have extended postfix.languages setting with c++ and others in order to use the extension there as well? This is a limitation of VSCode API. I can activate the extension based on fixed set of file types but this list cannot be dynamic and changed at runtime (makes sense because extensions would have to start first to modify it).

Currently the list is defined as this:

https://github.com/ipatalas/vscode-postfix-ts/blob/dc2d17be5f371e20ab8d3b1a535522a45aadddd0/package.json#L24-L30

This makes most sense because those are common types which can contain TS/JS code. Activating extensions all the time (for all files) is discouraged and I'd rather avoid that as this brings some other potential problems. One solution which I currently see is to also activate the extension when a certain file is present in your workspace. For instance this could be a file like .enable-postfix and when it's present extension will always start no matter which file is open when VSCode launches. Would that be helpful?

I'm sorry, I didn't find the Settings you said to configure extensions to load automatically on vscode startup as files, can you give a simple example? I would appreciate it

ipatalas commented 7 months ago

Hey, sorry, I didn't make myself clear. This is not implemented yet, it's an idea that came to my mind and I wanted to double check with you if that's something that will work for you before I implement it.

Cattle0Horse commented 7 months ago

I think it's a very good idea, and it can really solve my problem.

ipatalas commented 6 months ago

Sorry, took a while but I was busy and away for a week so I couldn't push it earlier. Anyway, it's there and works exactly as I described above so if you put .enable-postfix in root directory of your workspace the extension will be activated. Please update the extension and let me know if it works for you.

Cattle0Horse commented 6 months ago

Sorry for the late reply. Unfortunately it still doesn't seem to work.

ipatalas commented 6 months ago

Hmm, that's weird. Can you explain the structure of your project then a bit to help me understand?

Here is what I have tried and it works, a very simple workspaces with the following files (all in workspace root):

/.enable-postfix
/test.cs

Before that I have added csharp to postfix.languages settings so that postfix completions are available in .cs files which is not the default behavior. There are no JS/TS files in the workspace so I'm sure the extension is not activated by them by accident. I open this workspace directly in test.cs file and postfix completions simply work (extension is enabled by .enable-postfix file).

Is your situation similar or something is different? Let me know and we'll figure it out.

zardoy commented 6 months ago

I personally solved this problem in the past by installing Activator and adding this into settings: "activator.activateOnStart": ["ipatalas.vscode-postfix-ts"]

Cattle0Horse commented 6 months ago

Sorry for the late reply. I found out it was my fault, because the .enable-postfix file was not created. Thank you very much for your help.