thangnm
(Thang Nguyen)
October 28, 2020, 3:58am
#1
I try to make an Issue Provider by using IssueCollection.
I only want to validate when file is saved.
Nova can show issue. But then issue gone in a few seconds.
Please help me!
Here is my code:
nova.workspace.onDidAddTextEditor((editor) => {
editor.onDidSave((editor) => {
validator.validate(editor.document);
});
});
logan
(Logan Collins)
October 28, 2020, 5:13pm
#2
Hello! It appears you are not showing any code related to an IssueCollection. Could you please post the code for your validate()
function?
Also, have you considered using the AssistantRegistry issue provider, which will handle the callbacks on document save (or change) for you? https://docs.nova.app/api-reference/assistants-registry/#registerissueassistant-selector-object-options
thangnm
(Thang Nguyen)
October 29, 2020, 12:03am
#3
Thank @logan ,
Here is my code and demo gif.
I’m using Nova 2 (213794)
and macOS 10.15.7 (19H2)
exports.activate = function() {
let issueCollection = new IssueCollection();
nova.workspace.onDidAddTextEditor((editor) => {
editor.onDidSave((editor) => {
let issue = new Issue();
issue.message = 'Test issue collection in onDidSave';
issue.severity = IssueSeverity.Error;
issue.line = 1;
issue.column = 1;
issueCollection.set(editor.document.uri, [issue]);
});
});
}