Skip to content

Formatting selection fails with root element with mixed content #1414

@JessicaJHee

Description

@JessicaJHee

Given this XML:

<a>
    zz    <b>  </b>tt     </a>

If the whole XML is selected, the following NPR is generated;

[Error - 4:24:13 PM] Dec 15, 2022 04:24:13 org.eclipse.lsp4j.jsonrpc.RemoteEndpoint fallbackResponseError()
Message: Internal error: java.lang.NullPointerException: Cannot invoke "org.eclipse.lemminx.dom.DOMElement.getStartTagCloseOffset()" because the return value of "org.eclipse.lemminx.dom.DOMElement.getParentElement()" is null
java.util.concurrent.CompletionException: java.lang.NullPointerException: Cannot invoke "org.eclipse.lemminx.dom.DOMElement.getStartTagCloseOffset()" because the return value of "org.eclipse.lemminx.dom.DOMElement.getParentElement()" is null
	at java.base/java.util.concurrent.CompletableFuture.encodeThrowable(CompletableFuture.java:315)
	at java.base/java.util.concurrent.CompletableFuture.completeThrowable(CompletableFuture.java:320)
	at java.base/java.util.concurrent.CompletableFuture$UniApply.tryFire(CompletableFuture.java:649)
	at java.base/java.util.concurrent.CompletableFuture$Completion.exec(CompletableFuture.java:483)
	at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:373)
	at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1182)
	at java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1655)
	at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1622)
	at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:165)

This is caused by: https://github.com/eclipse/lemminx/blob/e5bfd0af4f2021f54cd3c2fc0b23ee8c36b13b47/o[…]va/org/eclipse/lemminx/services/format/DOMElementFormatter.java

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions