mirror of
https://github.com/godotengine/godot-vscode-plugin.git
synced 2025-12-31 13:48:24 +03:00
Merge pull request #596 from DaelonSuzuka:fix-goto-docs
Fix definition provider not working because of accessing a Map as an Object
This commit is contained in:
@@ -32,7 +32,7 @@ export class GDDefinitionProvider implements DefinitionProvider {
|
||||
const range = document.getWordRangeAtPosition(position, /(\w+)/);
|
||||
if (range) {
|
||||
const word = document.getText(range);
|
||||
if (globals.docsProvider.classInfo[word] !== undefined) {
|
||||
if (globals.docsProvider.classInfo.has(word)) {
|
||||
const uri = make_docs_uri(word);
|
||||
return new Location(uri, new Position(0, 0));
|
||||
} else {
|
||||
@@ -45,7 +45,7 @@ export class GDDefinitionProvider implements DefinitionProvider {
|
||||
match = line.text.match(/(?<=type)="(\w+)"/);
|
||||
} while (!match && line.lineNumber > 0);
|
||||
|
||||
if (globals.docsProvider.classInfo[match[1]] !== undefined) {
|
||||
if (globals.docsProvider.classInfo.has(match[1])) {
|
||||
const uri = make_docs_uri(match[1], word);
|
||||
return new Location(uri, new Position(0, 0));
|
||||
}
|
||||
|
||||
@@ -64,7 +64,7 @@ export class GDDocumentationProvider implements CustomReadonlyEditorProvider {
|
||||
|
||||
public async list_native_classes() {
|
||||
const classname = await vscode.window.showQuickPick(
|
||||
Object.keys(this.classInfo).sort(),
|
||||
[...this.classInfo.keys()].sort(),
|
||||
{
|
||||
placeHolder: "Type godot class name here",
|
||||
canPickMany: false,
|
||||
@@ -92,11 +92,9 @@ export class GDDocumentationProvider implements CustomReadonlyEditorProvider {
|
||||
await new Promise(resolve => setTimeout(resolve, 100));
|
||||
}
|
||||
|
||||
if (className in this.symbolDb) {
|
||||
symbol = this.symbolDb[className];
|
||||
}
|
||||
symbol = this.symbolDb.get(className);
|
||||
|
||||
if (!symbol && className in this.classInfo) {
|
||||
if (!symbol && this.classInfo.has(className)) {
|
||||
const params: NativeSymbolInspectParams = {
|
||||
native_class: className,
|
||||
symbol_name: className,
|
||||
@@ -105,13 +103,13 @@ export class GDDocumentationProvider implements CustomReadonlyEditorProvider {
|
||||
const response = await globals.lsp.client.sendRequest("textDocument/nativeSymbol", params);
|
||||
|
||||
symbol = response as GodotNativeSymbol;
|
||||
symbol.class_info = this.classInfo[symbol.name];
|
||||
this.symbolDb[symbol.name] = symbol;
|
||||
symbol.class_info = this.classInfo.get(symbol.name);
|
||||
this.symbolDb.set(symbol.name, symbol);
|
||||
}
|
||||
if (!this.htmlDb.has(className)) {
|
||||
this.htmlDb[className] = make_html_content(panel.webview, symbol, target);
|
||||
this.htmlDb.set(className, make_html_content(panel.webview, symbol, target));
|
||||
}
|
||||
panel.webview.html = this.htmlDb[className];
|
||||
panel.webview.html = this.htmlDb.get(className);
|
||||
panel.iconPath = get_extension_uri("resources/godot_icon.svg");
|
||||
panel.webview.onDidReceiveMessage(msg => {
|
||||
if (msg.type === "INSPECT_NATIVE_SYMBOL") {
|
||||
|
||||
Reference in New Issue
Block a user