private bool OnQuoteTyped()

in Backend/Core/ForTea.Core/Services/TypingAssist/T4TypingAssist.cs [90:124]


    private bool OnQuoteTyped([NotNull] ITypingContext context)
    {
      var textControl = context.TextControl;
      var cachingLexer = GetCachingLexer(textControl);
      if (cachingLexer == null) return false;
      var offset = textControl.Caret.DocumentOffset();
      if (!cachingLexer.FindTokenAt(offset.Offset)) return false;
      var tokenType = cachingLexer.TokenType;

      // C# is handled by T4CSharpTypingAssist. Text tokens are handled by the platform
      if (tokenType is ICSharpTokenNodeType || tokenType == T4TokenNodeTypes.RAW_TEXT) return false;

      // The second quote has already been inserted. Over-type it
      if (tokenType == T4TokenNodeTypes.QUOTE)
      {
        textControl.Caret.MoveTo(offset + 1, CaretVisualPlacement.DontScrollIfVisible);
        return true;
      }

      // insert the first quote
      textControl.Selection.Delete();
      textControl.FillVirtualSpaceUntilCaret();
      textControl.Document.InsertText(offset, "\"");

      // insert the second quote
      using (CommandProcessor.UsingCommand("Smart quote in T4"))
      {
        textControl.Document.InsertText(offset + 1, "\"");
        textControl.Caret.MoveTo(offset + 1, CaretVisualPlacement.DontScrollIfVisible);
      }

      _codeCompletionSessionManager.ExecuteAutoCompletion<T4AutopopupSettingsKey>(textControl, Solution,
        key => key.InDirectives);
      return true;
    }