I'm trying to get into developing an extension for Visual Studio for Mac. I'm using this tutorial. Everything had been going well until I tried to run my extension. In my case "Insert date" in Edit submenu is disabled. While debugging I've noticed that IdeApp.Workbench.ActiveDocument.Editor is null despite I have an open document. Here's my code
using System;
using MonoDevelop.Components.Commands;
using MonoDevelop.Ide;
namespace ExampleIDEExtension
{
public class InsertDateHandler : CommandHandler
{
protected override void Run()
{
var editor = IdeApp.Workbench.ActiveDocument.Editor;
var currentTime = DateTime.Now.ToString();
editor.InsertAtCaret(currentTime);
}
protected override void Update(CommandInfo info)
{
info.Enabled = IdeApp.Workbench.ActiveDocument.Editor != null;
}
}
}
I have no idea why Editor is null despite having an open document.