﻿using Monaco;
using Monaco.Editor;
using Monaco.Languages;
using System;
using System.Runtime.InteropServices.WindowsRuntime;
using System.Threading;
using Windows.Foundation;

namespace MonacoEditorTestApp.Helpers
{
    class EditorHoverProvider : HoverProvider
    {
        public IAsyncOperation<Hover> ProvideHover(IModel model, Position position)
        {
            return AsyncInfo.Run(async delegate (CancellationToken cancelationToken)
            {
                var word = await model.GetWordAtPositionAsync(position);
                if (word != null && word.Word != null && word.Word.IndexOf("Hit", 0, StringComparison.CurrentCultureIgnoreCase) != -1)
                {
                    return new Hover(new string[]
                    {
                        "*Hit* - press the keys following together.",
                        "Some **more** text is here.",
                        "And a [link](https://www.github.com/)."
                    }, new Range(position.LineNumber, position.Column, position.LineNumber, position.Column + 5));
                }

                return default(Hover);
            });
        }
    }
}

﻿using Monaco;
using Monaco.Editor;
using Monaco.Languages;
using System;
using System.Runtime.InteropServices.WindowsRuntime;
using System.Threading;
using Windows.Foundation;

namespace MonacoEditorTestApp.Helpers
{
    class EditorHoverProvider : HoverProvider
    {
        public IAsyncOperation<Hover> ProvideHover(IModel model, Position position)
        {
            return AsyncInfo.Run(async delegate (CancellationToken cancelationToken)
            {
                var word = await model.GetWordAtPositionAsync(position);
                if (word != null && word.Word != null && word.Word.IndexOf("Hit", 0, StringComparison.CurrentCultureIgnoreCase) != -1)
                {
                    return new Hover(new string[]
                    {
                        "*Hit* - press the keys following together.",
                        "Some **more** text is here.",
                        "And a [link](https://www.github.com/)."
                    }, new Range(position.LineNumber, word.StartColumn, position.LineNumber, word.EndColumn));
                }

                return default(Hover);
            });
        }
    }
}

Fix another issue where the word Hit wasn't highlighted from the start.
Fix another issue where the word Hit wasn't highlighted from the start.
