Ejemplo n.º 1
0
        private static void EnsureFirstWordIsSelected(ScNotification notification)
        {
            if (isPluginActive)
            {
                nppResource.ClearIndicator();

                if (notification.Header.Code == (ulong)SciMsg.SCN_UPDATEUI)
                {
                    var scintillaGateway = new ScintillaGateway(PluginBase.GetCurrentScintilla());
                    var currentPosition  = scintillaGateway.GetCurrentPos();
                    if (currentPosition != lastPositionWhenUiUpdate)
                    {
                        if (scintillaGateway.GetSelectionEmpty())
                        {
                            lastPositionWhenUiUpdate = firstWordSelector.SelectFirstWordOfLine(scintillaGateway);
                        }
                    }
                    return;
                }

                if (notification.Header.Code == (ulong)SciMsg.SCN_MODIFIED)
                {
                    var isTextInsertedOrDeleted = (notification.ModificationType &
                                                   ((int)SciMsg.SC_MOD_INSERTTEXT | (int)SciMsg.SC_MOD_DELETETEXT)) > 0;
                    if (isTextInsertedOrDeleted)
                    {
                        lastPositionWhenUiUpdate = null;
                    }
                }
            }
        }