Skip to content

Comments

fix: Rename both tags when one is being edited#3925

Open
Nishthajain7 wants to merge 2 commits intoprocessing:develop-codemirror-v6from
Nishthajain7:Auto-rename-tag
Open

fix: Rename both tags when one is being edited#3925
Nishthajain7 wants to merge 2 commits intoprocessing:develop-codemirror-v6from
Nishthajain7:Auto-rename-tag

Conversation

@Nishthajain7
Copy link

Issue:

Fixes #3873

Demo:

Screencast.from.2026-02-22.21-24-21.webm

Changes:

I used syntaxTree from codemirror to traverse through an html tree and find the corresponding closing tag of the opening tag that is being edited.

I have verified that this pull request:

  • has no linting errors (npm run lint)
  • has no test errors (npm run test)
  • has no typecheck errors (npm run typecheck)
  • is from a uniquely-named feature branch and is up to date with the develop branch.
  • is descriptively named and links to an issue number, i.e. Fixes #123
  • meets the standards outlined in the accessibility guidelines

@Jatin24062005
Copy link
Contributor

Jatin24062005 commented Feb 22, 2026

The overall approach looks solid and CM6-native
Using the syntax tree to sync opening and closing tags (with an annotation guard to avoid recursion) seems like a good fit for this regression.
One small process note: for changes of this size, it’s usually helpful to comment on the issue and wait for maintainer confirmation or assignment before opening a PR.

@yugalkaushik
Copy link
Contributor

Looks good but for instance where I have not provided a closing tag and I'll rename the current tag then won't it affect the next closing tag. If not please show the demo.

@Nishthajain7
Copy link
Author

I made a new commit to handle the no closing tag case

Screencast.from.2026-02-23.22-47-44.webm

import { HTMLHint } from 'htmlhint';
import { CSSLint } from 'csslint';
import { emmetConfig } from '@emmetio/codemirror6-plugin';
import { syntaxTree } from '@codemirror/language';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

import { syntaxTree } from '@codemirror/language' and import { Annotation } from '@codemirror/state' are already available through the existing package imports so please add them there instead of introducing new ones.

if (!oldCloseTag) return;

let parentHasCloseTag = false;
let pc = oldParentElement?.firstChild;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Undescriptive variable name pc, better to use parentChild

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants