Skip to content

Commit

Permalink
Improve behavior on edge cases
Browse files Browse the repository at this point in the history
  • Loading branch information
DaelonSuzuka committed Jan 4, 2025
1 parent ea0f0e9 commit 5afba0b
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/providers/document_drops.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,24 +41,24 @@ export class GDDocumentDropEditProvider implements DocumentDropEditProvider {
// "main" script for that scene?
// Attempt to calculate a relative path that resolves correctly?

const path: string = dataTransfer.get("godot/path")?.value;
if (path) {
const className: string = dataTransfer.get("godot/class")?.value;
const line = document.lineAt(position.line);
const className: string = dataTransfer.get("godot/class")?.value;
if (className) {
const path: string = dataTransfer.get("godot/path")?.value;
const unique = dataTransfer.get("godot/unique")?.value === "true";
const label: string = dataTransfer.get("godot/label")?.value;

// For the root node, the path is empty and needs to be replaced with the node name
const savePath = path || label;

if (document.languageId === "gdscript") {
const snippet = new vscode.SnippetString();
let qualifiedPath = `$${savePath}`;

if (unique) {
// For unique nodes, we can use the % syntax and drop the full path
qualifiedPath = `%${label}`;
}

const line = document.lineAt(position.line);
if (line.text === "") {
// We assume that if the user is dropping a node in an empty line, they are at the top of
// the script and want to declare an onready variable
Expand Down

0 comments on commit 5afba0b

Please sign in to comment.