Within an extension, I open a new TextEditor with
nova.workspace.openNewTextDocument({
content: "",
syntax: "json",
})
Since I need to populate the content incrementally, I thought maybe openNewTextDocument()
actually returns something, and indeed it does return a Promise. So this should work:
nova.workspace.openNewTextDocument({
content: "",
syntax: "json",
}).then(doc => {
console.log("doc", doc);
doc.insert("Hello, World");
});
The issue is, that it sometimes returns a Promise, and sometimes it just returns undefined
:
HTTP Client[16:26:44.328000] doc [object NovaJSTextEditor]
HTTP Client[16:26:50.451000] doc [object NovaJSTextEditor]
HTTP Client[16:26:55.988000] doc undefined
HTTP Client[16:26:56.144000] TypeError: undefined is not an object (evaluating 'doc.insert')
It happens around in 30-50% that the value returned from the Promise is undefined.
Since the documentation does not indicate about any return value from openNewTextDocument()
, my question is: is this bug or am I doing something wrong here?
Thanks for your support!
Louis