zjffun / vscode-snippets-manager

Create and edit snippets easily.
https://marketplace.visualstudio.com/items?itemName=zjffun.snippetsmanager
MIT License
38 stars 7 forks source link

Cooperation with profiles #8

Open KPiach opened 1 year ago

KPiach commented 1 year ago

VSCode supports the ability to create profiles. When using profiles, the snippet paths change, which means that the extension does not find user snippets and VSCode cannot see the user snippet from files created by the extension.

zjffun commented 1 year ago

Thank you. We will try to fix this, but it seems to get --user-data-dir is hard currently.

https://github.com/microsoft/vscode/issues/37442 https://github.com/microsoft/vscode/issues/2741

zjffun commented 1 year ago

I try to use --user-data-dir but can't reproduce this bug.

code --user-data-dir ~/vscode-user-data-dir-test
Screen Shot 2023-01-24 at 12 30 40

Could you give us more information about profiles, Operating System, code -v or code --verbose to help us reproduce this?

code -v
1.74.2
e8a3071ea4344d9d48ef8a4df2c097372b0c5161
arm64

code --user-data-dir ~/vscode-user-data-dir-test --verbose
[main 2023-01-24T04:43:32.989Z] [File Watcher (node.js)] Request to start watching: /Users/zjf/vscode-user-data-dir-test/User (excludes: <none>, includes: <all>),/Users/zjf/vscode-user-data-dir-test/User/settings.json (excludes: <none>, includes: <all>)
[main 2023-01-24T04:43:32.995Z] Sending env to running instance...
[main 2023-01-24T04:43:32.995Z] [File Watcher (node.js)] Error: ENOENT: no such file or directory, stat '/Users/zjf/vscode-user-data-dir-test/User/settings.json'
[main 2023-01-24T04:43:32.996Z] [File Watcher (node.js)] Started watching: '/Users/zjf/vscode-user-data-dir-test/User'
[main 2023-01-24T04:43:33.029Z] Sent env to running instance. Terminating...
[main 2023-01-24T04:43:33.029Z] Lifecycle#kill()
[main 2023-01-24T04:43:33.029Z] Lifecycle#onWillShutdown.fire()
[30850:0124/124333.036455:WARNING:pref_notifier_impl.cc(60)] Init observer found at shutdown.
KPiach commented 1 year ago

My VSC: image I have configured some profiles: image If I use VSC snippet command for create snippet file, it will be in: image and I can use snippets normally (for clarification, -59cf7cf2 is a subdirectory of my profile named Python). This file is not seen by the extension. On the other hand, if I create a snippet file by extension, it will be located in ..\Code\User\snippets\ and not available in the editor.

KPiach commented 1 year ago

Now I have a more serious problem. Versions 0.1.13 and 0.1.14 of the extension do not work. Log in the Output Extension host window:

2023-01-25 22:57:58.615 [info] ExtensionService#_doActivateExtension zjffun.snippetsmanager, startup: false, activationEvent: 'onStartupFinished'
2023-01-25 22:57:59.193 [error] Activating extension zjffun.snippetsmanager failed due to an error:
2023-01-25 22:57:59.193 [error] Error: Cannot find module 'sha1'
Require stack:
- c:\Users\Krzysiek\.vscode\extensions\zjffun.snippetsmanager-0.1.14\out\commands\editSnippetBody.js
- c:\Users\Krzysiek\.vscode\extensions\zjffun.snippetsmanager-0.1.14\out\CodeSnippetsEditor.js
- c:\Users\Krzysiek\.vscode\extensions\zjffun.snippetsmanager-0.1.14\out\extension.js
- c:\Program Files\Microsoft VS Code\resources\app\out\vs\loader.js
- c:\Program Files\Microsoft VS Code\resources\app\out\bootstrap-amd.js
- c:\Program Files\Microsoft VS Code\resources\app\out\bootstrap-fork.js
    at Module._resolveFilename (node:internal/modules/cjs/loader:987:15)
    at Module._load (node:internal/modules/cjs/loader:832:27)
    at c._load (node:electron/js2c/asar_bundle:5:13343)
    at r._load (c:\Program Files\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:120:13379)
    at w._load (c:\Program Files\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:115:61900)
    at v._load (c:\Program Files\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:115:61293)
    at Module.require (node:internal/modules/cjs/loader:1059:19)
    at p (c:\Program Files\Microsoft VS Code\resources\app\out\vs\loader.js:4:699)
    at Object.<anonymous> (c:\Users\Krzysiek\.vscode\extensions\zjffun.snippetsmanager-0.1.14\out\commands\editSnippetBody.js:17:14)
    at u._compile (c:\Program Files\Microsoft VS Code\resources\app\out\vs\loader.js:4:1313)
    at Module._extensions..js (node:internal/modules/cjs/loader:1220:10)
    at Module.load (node:internal/modules/cjs/loader:1035:32)
    at Module._load (node:internal/modules/cjs/loader:876:12)
    at c._load (node:electron/js2c/asar_bundle:5:13343)
    at r._load (c:\Program Files\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:120:13379)
    at w._load (c:\Program Files\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:115:61900)
    at v._load (c:\Program Files\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:115:61293)
    at Module.require (node:internal/modules/cjs/loader:1059:19)
    at p (c:\Program Files\Microsoft VS Code\resources\app\out\vs\loader.js:4:699)
    at Object.<anonymous> (c:\Users\Krzysiek\.vscode\extensions\zjffun.snippetsmanager-0.1.14\out\CodeSnippetsEditor.js:17:27)
    at u._compile (c:\Program Files\Microsoft VS Code\resources\app\out\vs\loader.js:4:1313)
    at Module._extensions..js (node:internal/modules/cjs/loader:1220:10)
    at Module.load (node:internal/modules/cjs/loader:1035:32)
    at Module._load (node:internal/modules/cjs/loader:876:12)
    at c._load (node:electron/js2c/asar_bundle:5:13343)
    at r._load (c:\Program Files\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:120:13379)
    at w._load (c:\Program Files\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:115:61900)
    at v._load (c:\Program Files\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:115:61293)
    at Module.require (node:internal/modules/cjs/loader:1059:19)
    at p (c:\Program Files\Microsoft VS Code\resources\app\out\vs\loader.js:4:699)
    at Object.<anonymous> (c:\Users\Krzysiek\.vscode\extensions\zjffun.snippetsmanager-0.1.14\out\extension.js:17:30)
    at u._compile (c:\Program Files\Microsoft VS Code\resources\app\out\vs\loader.js:4:1313)
    at Module._extensions..js (node:internal/modules/cjs/loader:1220:10)
    at Module.load (node:internal/modules/cjs/loader:1035:32)
    at Module._load (node:internal/modules/cjs/loader:876:12)
    at c._load (node:electron/js2c/asar_bundle:5:13343)
    at r._load (c:\Program Files\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:120:13379)
    at w._load (c:\Program Files\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:115:61900)
    at v._load (c:\Program Files\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:115:61293)
    at Module.require (node:internal/modules/cjs/loader:1059:19)
    at require (node:internal/modules/cjs/helpers:102:18)
    at Function.r [as __$__nodeRequire] (c:\Program Files\Microsoft VS Code\resources\app\out\vs\loader.js:5:101)
    at d.pb (c:\Program Files\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:115:63164)
    at process.processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async Promise.all (index 0)

Last working version is 0.1.12.

zjffun commented 1 year ago

Now I have a more serious problem. Versions 0.1.13 and 0.1.14 of the extension do not work. Log in the Output Extension host window:

2023-01-25 22:57:58.615 [info] ExtensionService#_doActivateExtension zjffun.snippetsmanager, startup: false, activationEvent: 'onStartupFinished'
2023-01-25 22:57:59.193 [error] Activating extension zjffun.snippetsmanager failed due to an error:
2023-01-25 22:57:59.193 [error] Error: Cannot find module 'sha1'
Require stack:
- c:\Users\Krzysiek\.vscode\extensions\zjffun.snippetsmanager-0.1.14\out\commands\editSnippetBody.js
- c:\Users\Krzysiek\.vscode\extensions\zjffun.snippetsmanager-0.1.14\out\CodeSnippetsEditor.js
- c:\Users\Krzysiek\.vscode\extensions\zjffun.snippetsmanager-0.1.14\out\extension.js
- c:\Program Files\Microsoft VS Code\resources\app\out\vs\loader.js
- c:\Program Files\Microsoft VS Code\resources\app\out\bootstrap-amd.js
- c:\Program Files\Microsoft VS Code\resources\app\out\bootstrap-fork.js
  at Module._resolveFilename (node:internal/modules/cjs/loader:987:15)
  at Module._load (node:internal/modules/cjs/loader:832:27)
  at c._load (node:electron/js2c/asar_bundle:5:13343)
  at r._load (c:\Program Files\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:120:13379)
  at w._load (c:\Program Files\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:115:61900)
  at v._load (c:\Program Files\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:115:61293)
  at Module.require (node:internal/modules/cjs/loader:1059:19)
  at p (c:\Program Files\Microsoft VS Code\resources\app\out\vs\loader.js:4:699)
  at Object.<anonymous> (c:\Users\Krzysiek\.vscode\extensions\zjffun.snippetsmanager-0.1.14\out\commands\editSnippetBody.js:17:14)
  at u._compile (c:\Program Files\Microsoft VS Code\resources\app\out\vs\loader.js:4:1313)
  at Module._extensions..js (node:internal/modules/cjs/loader:1220:10)
  at Module.load (node:internal/modules/cjs/loader:1035:32)
  at Module._load (node:internal/modules/cjs/loader:876:12)
  at c._load (node:electron/js2c/asar_bundle:5:13343)
  at r._load (c:\Program Files\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:120:13379)
  at w._load (c:\Program Files\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:115:61900)
  at v._load (c:\Program Files\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:115:61293)
  at Module.require (node:internal/modules/cjs/loader:1059:19)
  at p (c:\Program Files\Microsoft VS Code\resources\app\out\vs\loader.js:4:699)
  at Object.<anonymous> (c:\Users\Krzysiek\.vscode\extensions\zjffun.snippetsmanager-0.1.14\out\CodeSnippetsEditor.js:17:27)
  at u._compile (c:\Program Files\Microsoft VS Code\resources\app\out\vs\loader.js:4:1313)
  at Module._extensions..js (node:internal/modules/cjs/loader:1220:10)
  at Module.load (node:internal/modules/cjs/loader:1035:32)
  at Module._load (node:internal/modules/cjs/loader:876:12)
  at c._load (node:electron/js2c/asar_bundle:5:13343)
  at r._load (c:\Program Files\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:120:13379)
  at w._load (c:\Program Files\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:115:61900)
  at v._load (c:\Program Files\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:115:61293)
  at Module.require (node:internal/modules/cjs/loader:1059:19)
  at p (c:\Program Files\Microsoft VS Code\resources\app\out\vs\loader.js:4:699)
  at Object.<anonymous> (c:\Users\Krzysiek\.vscode\extensions\zjffun.snippetsmanager-0.1.14\out\extension.js:17:30)
  at u._compile (c:\Program Files\Microsoft VS Code\resources\app\out\vs\loader.js:4:1313)
  at Module._extensions..js (node:internal/modules/cjs/loader:1220:10)
  at Module.load (node:internal/modules/cjs/loader:1035:32)
  at Module._load (node:internal/modules/cjs/loader:876:12)
  at c._load (node:electron/js2c/asar_bundle:5:13343)
  at r._load (c:\Program Files\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:120:13379)
  at w._load (c:\Program Files\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:115:61900)
  at v._load (c:\Program Files\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:115:61293)
  at Module.require (node:internal/modules/cjs/loader:1059:19)
  at require (node:internal/modules/cjs/helpers:102:18)
  at Function.r [as __$__nodeRequire] (c:\Program Files\Microsoft VS Code\resources\app\out\vs\loader.js:5:101)
  at d.pb (c:\Program Files\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:115:63164)
  at process.processTicksAndRejections (node:internal/process/task_queues:96:5)
  at async Promise.all (index 0)

Last working version is 0.1.12.

Thank you 🙏, we publish v0.1.15 to fix this bug. We bring this bug when make it support web editor.

zjffun commented 1 year ago

image

Got it, I find this feature in Visual Studio Code November 2022.

zjffun commented 1 year ago

Wait for https://github.com/microsoft/vscode/issues/160466 to be implemented.