Skip to content

"format selection" changing entire document #1059

@jamesford42

Description

@jamesford42

See original post (inappropriately), in the vscode repository.
microsoft/vscode#241129

TLDR; copypasta for your reading pleasure!

With an xml document open i drag select some lines of it and ctrl-k,ctrl-f or using context menu "format selection". Normally this does in fact just format the selection. However, very very frequently I end up in a state where instead it formats the entire document.

I just tracked down the cause, or at least how to reproduce it, and its super dumb. So, If you drag select exactly and only the xml element you want formatted it seems to only format that. If you have even a single line of whitespace above or below it, it formats the entire document. This also means, you cannot drag select and reformat two consecutive elements separated by whitespace, since the whitespace between them makes it think (apparently) that you want to format the entire root node ...

Actually its even worse than that. If you have even a single space character selected before the start of the element, or after it, the same occurs. So .. you paste in something and it has incorrect tabs/indents, typical issue to have. You cannot drag select the lines and reformat them. You have to drag select exactly from the elements open tag to close tag.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

Status

Done

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions