mirror of
https://github.com/godotengine/godot-vscode-plugin.git
synced 2025-12-31 13:48:24 +03:00
Improve displaying symbols documentation (#404)
Co-authored-by: Tomasz Wyrowiński <tomasz.wyrowinski@10clouds.com>
This commit is contained in:
committed by
GitHub
parent
ef450cad38
commit
f2145688b1
16
package-lock.json
generated
16
package-lock.json
generated
@@ -24,14 +24,14 @@
|
||||
"@types/mocha": "^9.1.0",
|
||||
"@types/node": "^10.12.21",
|
||||
"@types/prismjs": "^1.16.8",
|
||||
"@types/vscode": "^1.33.0",
|
||||
"@types/vscode": "^1.68.0",
|
||||
"@types/ws": "^8.2.2",
|
||||
"tslint": "^5.20.1",
|
||||
"typescript": "^3.5.1",
|
||||
"vsce": "^2.6.4"
|
||||
},
|
||||
"engines": {
|
||||
"vscode": "^1.33.0"
|
||||
"vscode": "^1.68.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@babel/code-frame": {
|
||||
@@ -85,9 +85,9 @@
|
||||
"dev": true
|
||||
},
|
||||
"node_modules/@types/vscode": {
|
||||
"version": "1.55.0",
|
||||
"resolved": "https://registry.npmjs.org/@types/vscode/-/vscode-1.55.0.tgz",
|
||||
"integrity": "sha512-49hysH7jneTQoSC8TWbAi7nKK9Lc5osQNjmDHVosrcU8o3jecD9GrK0Qyul8q4aGPSXRfNGqIp9CBdb13akETg==",
|
||||
"version": "1.68.0",
|
||||
"resolved": "https://registry.npmjs.org/@types/vscode/-/vscode-1.68.0.tgz",
|
||||
"integrity": "sha512-duBwEK5ta/eBBMJMQ7ECMEsMvlE3XJdRGh3xoS1uOO4jl2Z4LPBl5vx8WvBP10ERAgDRmIt/FaSD4RHyBGbChw==",
|
||||
"dev": true
|
||||
},
|
||||
"node_modules/@types/ws": {
|
||||
@@ -1888,9 +1888,9 @@
|
||||
"dev": true
|
||||
},
|
||||
"@types/vscode": {
|
||||
"version": "1.55.0",
|
||||
"resolved": "https://registry.npmjs.org/@types/vscode/-/vscode-1.55.0.tgz",
|
||||
"integrity": "sha512-49hysH7jneTQoSC8TWbAi7nKK9Lc5osQNjmDHVosrcU8o3jecD9GrK0Qyul8q4aGPSXRfNGqIp9CBdb13akETg==",
|
||||
"version": "1.68.0",
|
||||
"resolved": "https://registry.npmjs.org/@types/vscode/-/vscode-1.68.0.tgz",
|
||||
"integrity": "sha512-duBwEK5ta/eBBMJMQ7ECMEsMvlE3XJdRGh3xoS1uOO4jl2Z4LPBl5vx8WvBP10ERAgDRmIt/FaSD4RHyBGbChw==",
|
||||
"dev": true
|
||||
},
|
||||
"@types/ws": {
|
||||
|
||||
16
package.json
16
package.json
@@ -15,7 +15,7 @@
|
||||
"author": "The Godot Engine community",
|
||||
"publisher": "geequlim",
|
||||
"engines": {
|
||||
"vscode": "^1.33.0"
|
||||
"vscode": "^1.68.0"
|
||||
},
|
||||
"categories": [
|
||||
"Programming Languages",
|
||||
@@ -165,6 +165,18 @@
|
||||
"type": "boolean",
|
||||
"default": false,
|
||||
"description": "Force the project to run with visible navigation meshes"
|
||||
},
|
||||
"godot_tools.native_symbol_placement": {
|
||||
"enum": [
|
||||
"active",
|
||||
"beside"
|
||||
],
|
||||
"enumDescriptions": [
|
||||
"Place the native symbol window in the active tabs group",
|
||||
"Place the native symbol window beside the active tabs group"
|
||||
],
|
||||
"default": "beside",
|
||||
"description": "Where to place the native symbol windows"
|
||||
}
|
||||
}
|
||||
},
|
||||
@@ -378,7 +390,7 @@
|
||||
"@types/mocha": "^9.1.0",
|
||||
"@types/node": "^10.12.21",
|
||||
"@types/prismjs": "^1.16.8",
|
||||
"@types/vscode": "^1.33.0",
|
||||
"@types/vscode": "^1.68.0",
|
||||
"@types/ws": "^8.2.2",
|
||||
"tslint": "^5.20.1",
|
||||
"typescript": "^3.5.1",
|
||||
|
||||
@@ -104,7 +104,7 @@ export default class NativeDocumentManager extends EventEmitter {
|
||||
const panel = vscode.window.createWebviewPanel(
|
||||
"doc",
|
||||
symbol.name,
|
||||
vscode.ViewColumn.Nine,
|
||||
this.get_new_native_symbol_column(),
|
||||
{
|
||||
enableScripts: true, // 启用JS,默认禁用
|
||||
retainContextWhenHidden: false, // webview被隐藏时保持状态,避免被重置
|
||||
@@ -116,6 +116,39 @@ export default class NativeDocumentManager extends EventEmitter {
|
||||
panel.webview.onDidReceiveMessage(this.on_webview_message.bind(this));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns placement for a new native symbol window based on the extension
|
||||
* configuration and previously opened native symbols.
|
||||
*/
|
||||
private get_new_native_symbol_column(): vscode.ViewColumn {
|
||||
const config_placement = get_configuration("native_symbol_placement", "beside");
|
||||
|
||||
if (config_placement == "active") {
|
||||
return vscode.ViewColumn.Active;
|
||||
}
|
||||
|
||||
const tab_groups = vscode.window.tabGroups;
|
||||
const visible_text_editors = vscode.window.visibleTextEditors;
|
||||
const editor_columns = visible_text_editors.map(editor => editor.viewColumn);
|
||||
|
||||
// Assume the first non-editor column is the column where other native
|
||||
// symbols have been opened.
|
||||
|
||||
const active_column = tab_groups.activeTabGroup.viewColumn;
|
||||
const is_non_editor_column_active = !editor_columns.includes(active_column);
|
||||
if (is_non_editor_column_active) {
|
||||
return active_column;
|
||||
}
|
||||
|
||||
const all_columns = tab_groups.all.map(group => group.viewColumn);
|
||||
const first_non_editor_column = all_columns.find(column => !editor_columns.includes(column));
|
||||
if (first_non_editor_column) {
|
||||
return first_non_editor_column;
|
||||
} else {
|
||||
return vscode.ViewColumn.Beside;
|
||||
}
|
||||
}
|
||||
|
||||
private on_webview_message(msg: any) {
|
||||
switch (msg.type) {
|
||||
case WebViewMessageType.INSPECT_NATIVE_SYMBOL:
|
||||
|
||||
Reference in New Issue
Block a user