@Override
    public void beforeDocumentChange(@NotNull DocumentEvent event) {
      if (!WebEditorOptions.getInstance().isSyncTagEditing()) return;

      final Document document = event.getDocument();
      Project project = Objects.requireNonNull(myEditor.getProject());
      if (myApplying || project.isDefault() || UndoManager.getInstance(project).isUndoInProgress() ||
          !PomModelImpl.isAllowPsiModification() || document.isInBulkUpdate()) {
        return;
      }

      final int offset = event.getOffset();
      final int oldLength = event.getOldLength();
      final CharSequence fragment = event.getNewFragment();
      final int newLength = event.getNewLength();

      if (document.getUserData(SKIP_COMMAND) == Boolean.TRUE) {
        // xml completion inserts extra space after tag name to ensure correct parsing
        // js auto-import may change beginning of the document when component is imported
        // we need to ignore it
        return;
      }

      Caret caret = myEditor.getCaretModel().getCurrentCaret();

      for (int i = 0; i < newLength; i++) {
        if (!isValidTagNameChar(fragment.charAt(i))) {
          clearMarkers(caret);
          return;
        }
      }

      Couple<RangeMarker> markers = getMarkers(caret);
      if (markers != null && !fitsInMarker(markers, offset, oldLength)) {
        clearMarkers(caret);
        markers = null;
      }

      int caretOffset = caret.getOffset();
      Segment floor = allMarkers.floor(new TextRange(caretOffset, caretOffset));
      // Skip markers creation if cursors cover same tag area as other cursors
      if (floor != null
          && (markers == null || (floor != markers.second && floor != markers.first))
          && caretOffset <= floor.getEndOffset()) {
        clearMarkers(caret);
        return;
      }

      if (markers == null) {
        final PsiFile file = myDocumentManager.getPsiFile(document);
        if (file == null || myDocumentManager.getSynchronizer().isInSynchronization(document)) return;

        final RangeMarker leader = createTagNameMarker(caret);
        if (leader == null) return;
        leader.setGreedyToLeft(true);
        leader.setGreedyToRight(true);

        if (myDocumentManager.isUncommited(document)) {
          myDocumentManager.commitDocument(document);
        }

        final RangeMarker support = findSupport(leader, file, document);
        if (support == null) return;
        support.setGreedyToLeft(true);
        support.setGreedyToRight(true);
        markers = Couple.of(leader, support);
        if (!fitsInMarker(markers, offset, oldLength)) return;
        setMarkers(caret, markers);
      }
    }
@Override
    public void beforeDocumentChange(@NotNull DocumentEvent event)