Forum Discussion
my-kl
May 12, 2021Brass Contributor
Why does Teams always strip indentation when pasting text?
It's fairly common to want to post code in teams (without using the special formatting for code snippets).
The markdown like syntax for code works pretty well when typing code and it preserves indentation. But when you paste XML or JSON all the indentation is removed. Why?
Here's an example:
That XML was indented in the source. But whenever we paste JSON or XML we lose indentation. Unless we take the extra effort to use a code snippet. Or manually type it for small examples.
my-kl
So I got to the heart of the matter. I used the Clipboard Inspector to inspect the contents of clipboard when copying the same text from two different apps. Both have two entries. One of the entries is text/html and one is text/plain. The text/plain as you might guess is identical. The html is quite different. I then copied the html and rendered.
This is what I see from TextEditThis is what I see from Visual Studio Code
So this would appear to be an issue with my environment in Visual Studio Code (or even a defect in Code, I"m not sure)
- Chris2K23Copper ContributorWho is reading this in 2045 and still have issues with formatting? Seriously...
- jeane710Copper Contributormadina eca
- kubermenschCopper Contributor
This is in fact worse in teams on Linux.
If i paste this code-snippet from here
<book id="bk101"> <author>Gambardella, Matthew</author> <title>XML Developer's Guide</title> <genre>Computer</genre> <price>44.95</price> <publish_date>2000-10-01</publish_date> <description>An in-depth look at creating applications with XML.</description> </book>
This is what it looks like when posted on linux
and when posted on windows 10
Teams version on Linux - You have Microsoft Teams Version 1.5.00.23861 (64-bit).
Teams version on Windows 10 - You have Microsoft Teams Version 1.5.00.31168 (64-bit). It was last updated on 11/25/22.
Linux distro:
Distributor ID: Ubuntu Description: Ubuntu 20.04.5 LTS Release: 20.04 Codename: focal
- PierreDumuid_kydCopper Contributor
This issue is causing considerable pain.
It seems in the last few weeks that pasting of text containing newlines in it are having them removed.
I confirmed that this is occurring both in windows and linux.
This should be a very high priority bug to fix - pasting many lines of console output to share with colleagues is extremely hard to read without manually re-inserting the newline characters.
Inserting a code-snippet is a slow work around, and forces titles and other painful UI experiences.
- WackyWixCopper Contributor
Can't even copy paste SQL code into Teams anymore, it is introducing non-breaking white spaces into the code, hex notation: 0xAO, instead of ASCII 32
So annoying!!!!
- Giacomo_Mc_EvoyCopper Contributor
Hard to believe that this discussion has been around for 1 year and nothing has changed. What needs to happen for Teams to be useful for exchanging code?
If I copy and paste code as a quote, I can see it gets stripped of whitespace while I am writing the message. If I fix this in the quote box and then send it, it still gets sent without the whitespace! This is simply unacceptable.
And I have tried the code snippet. Apart from being slow and clunky, if the lines are too wide then you cannot read the code from the chat. There aren't any scroll bars either, you just cannot read the code without blindly selecting the truncated rows and pasting them somewhere else.
- my-klBrass ContributorI just did a search for how to report an issue. One way is to use the Help | Give Feedback option within Teams itself, which I just did. We'll see if that helps.
- Giacomo_Mc_EvoyCopper Contributor
Hello! Thanks for answering. I also just noticed that this is a community forum, not exactly a bug reporting tool. I have also used Help -> Give Feedback, let's see if that helps somehow.
- my-klBrass Contributor
Giacomo_Mc_Evoy I think the issue is that I opened this up in a "community forum" rather than filing a bug in the appropriate place. I haven't investigated where bugs should be opened for Teams.
- dkaszews-intelCopper ContributorStill a problem on 1.5.00.5967. Anything pasted gets its leading whitespace trimmed, even when pasting into code block (!), making it unusable for pasting any code. Code snippets are not viable workaround, as they cannot be quickly accessed with mouse and are automatically collapsed.
- krzysztowCopper Contributor
dkaszews-intel fully agree it's like a broken feature atm, not usable...
- agallowayCTACopper ContributorTeams really needs to prioritize code formatting fixes if they ever want to be as useful as Slack and Discord are, which are currently both leagues ahead of Teams when it comes to developer communication.
I expect format preservation and language-specific syntax highlighting to be a standard feature in any modern chat client these days. I shouldn't have to spend more time fighting against the client to do what I need it to do than it takes to write the actual message. - hanvyjCopper Contributor
This needs fixing ASAP. It's absolutely ridiculous not to be able to paste code in a chat app and have it strip out whitespace.
It's not even whitespace at the start of lines, it strips out consecutive whitespace within pasted text too. Spaces, tabs, anything.I work in a team of software developers, it's outrageous such a simple thing doesn't work.
- dbompCopper Contributor...and the code snippet is not a substitute. It only displays five lines without expanding, and the entry is through a thought-interrupting popup. The "Monospaced" formatting was just fine for medium length pastes. (Actually, what is the point of monospaced formatting when the whitespace is collapsed? When is it even useful?)
- spinardCopper Contributor
dbomp Agreed code snippet is not a workaround. Not only for the reasons you stated, but also because you can't apply any other text formatting to the code snippet. One thing I do quite a bit (or used to) is paste a bit of code, then highlight the part I want to draw attention to. This woks in a Monospaced paragraph (but now the spaces are stripped so that's now useless).
- tilmanccviCopper ContributorThis happens with purely `text/plain` clipboard content, e.g. when copying from Notepad++, so this definitely is a bug in Teams not any specific source application.
- GregB945Copper Contributor
same issue when not pasting, but just typing... trying to write up pseudo-code to colleagues while explaining a concept, and all indentation, leading white space is stripped. Quite frustrating. I know we can spend the extra time to create a little code snippet tool, but when writing back and forth to colleagues on code design and concept, it just isn't practical
- NshawCopper Contributor
Yeah... Teams is total garbage. Let's not make excuses for Microsoft by saying the problem has a workaround. This is the most basic stuff there is.
If you copy plain text to your clipboard, you should be able to paste it into Teams without having it strip leading spaces. Copying from most applications will put plaint text as well as a few different forms of formatted text (rich-text, html). This way, if you are pasting to an application that understands those formats, you can keep all the extra colors/fonts/tables/etc. Many applications even give you this control when you paste, by having another option under the Edit menu that explicitly says, "Paste in plain text". The equivalent (you'd think) in Teams says "Paste and Match Style", except, it still strips your spaces.
I noticed recently that when I'm typing a message in Teams, typing cmd-a (the equivalent of ctrl-a on Windows), that shortcut seems to be completely ignored. I can click Edit > Select All... but I don't want to touch the mouse for a shortcut that Microsoft invented... it's been around since at least Windows 3.0. How is it that they keep managing to bugger up TYPING in Teams?!?
- GregB945Copper Contributor
Nshaw funny you say that, I (on a Windows machine, therefore using ctrl + a) also have the same issue lately, it's like they completely removed keyboard shortcuts.
There are many times I am typing a response and the conversation goes a different direction while I type and therefore need to trash what I was writing, going to try ctrl + a and rewrite a new message, I now need to use my mouse just to delete the current text... frustrating!