Skip to content

Commit

Permalink
Merge pull request #596 from DaelonSuzuka:fix-goto-docs
Browse files Browse the repository at this point in the history
Fix definition provider not working because of accessing a Map as an Object
  • Loading branch information
DaelonSuzuka authored Feb 23, 2024
2 parents a8a852b + 93e49e4 commit c129098
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 11 deletions.
4 changes: 2 additions & 2 deletions src/providers/definition.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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));
}
Expand Down
16 changes: 7 additions & 9 deletions src/providers/documentation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand All @@ -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") {
Expand Down

0 comments on commit c129098

Please sign in to comment.