@Dale-Lin
2021-01-06T14:47:58.000000Z
字数 1516
阅读 1072
VSCode开发
onDebug:todo
package.json 文件中的 activationEvnets 字段是一个 JSON 数组。当 activation events 触发时,插件会被激活。
当一个被解析为某种 language 的文件打开时触发,接收一个指定的 language 值。
..."activationEvents": ["onLanguage:python","onLanguage:json"]...
当一个 command 被调用时触发。
..."activationEvent": ["onCommand:extension.sayHello"]...
当工作区文件夹中至少包含一个匹配 glob pattern 表达式的文件时触发。
..."activationEvents": ["workspaceContains:**/.editorconfig"]...
当工作区文件或文件夹来自特定 scheme(协议)的时候触发。通常是 file scheme,在特殊 fs 中可能是 ftp、ssh 等。
..."activateEvents": ["onFileSystem:sftp"]...
当一个特定 id 的 view 在 VSCode 边栏展开的时候触发。
扩展程序或者资源管理都属于内置 views 的例子。
..."activationEvents": ["onView:nodeDependencies"]...
当系统范围内,扩展程序的 Uri 在 scheme 为 vscode 或 vscode-insiders 的情况下打开时触发。
..."activationEvents": ["onUri"]...
例如,当前扩展程序为 demo-sample.git,且指定了 onUri 触发事件,在下列 Uris 被打开时会被激活:
vscode://demo-sample.git/initvscode://demo-sample.git/clone?url=anyUrlvscode-insiders://demo-sample.git/init当 VSCode 需要恢复某种 viewType 的 webview 时触发。
..."activationEvents": ["onWebviewPanel:catCoding"]...
上例中,当 VSCode 需要恢复 viewType 为 catCoding 的 webview 时会激活插件。ViewType 在 window.createWebviewPanel 方法中设置,因此插件需要另一个 activation events 中激活程序,然后新建 webview。
当 VSCode 需要新建一个匹配 viewType 的自定义编辑器时触发。
..."activationEvents": ["onCustomEditor:catCustoms.pawDraw"]...
*当 VSCode 启动时,* activation event 会被触发。
为了保证使用体验,只有在确保其他事件都不能触发扩展程序时,才使用
*。
..."activationEvents": ["*"]...
当 VSCode 启动后一段时间后触发。
..."activationEvents": ["onStartupFinished"]...
