Forum Discussion

my-kl's avatar
my-kl
Brass Contributor
May 12, 2021
Solved

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 TextEdit

     

    This 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)

     

    • my-kl's avatar
      my-kl
      Brass Contributor
      I'm the OP. My guess is this is not the correct place for bug reports. I'm not sure what the correct forum to report bugs for Teams is.
      • michaelfs's avatar
        michaelfs
        Copper Contributor

        MS has been ignoring our bug reports for months at this point. I have no idea why my company switched to this garbage pile.

  • WeetA's avatar
    WeetA
    Copper Contributor
    Yop,
    I had the habit of pasting using CTRL+SHIFT+v inside a monospaced block created with triple backquotes.
    Indent was OK.
    Since few weeks, it doesn't work anymore.
    Indent is lost.
    Not sure why
  • my-kl's avatar
    my-kl
    Brass Contributor
    This is on macOS, colleagues tell me they don't have an issue on Windows.
    • mpowrie1's avatar
      mpowrie1
      Copper Contributor
      For the past few weeks I have this problem on Windows 10 and VS Code
      • __om__'s avatar
        __om__
        Copper Contributor

        I started to observe the issue with stripped spaces and tabs for preformatted text pasted may be month ago (Windows 10).
        The most annoying thing is inserting the code parts (even from Notepad or Notepad++).
        Is there any workaround for this?

    • my-kl's avatar
      my-kl
      Brass Contributor
      Ok some more sleuthing:

      If I copy from Visual Studio Code and paste into Teams (on macOS) this problem happens.

      If I copy from TextEdit or Visual Studio and paste into Teams, the indentation is fine.

      So this is weird interaction between Teams, the clipboard and Visual Studio Code.

      But, I can copy from Visual Studio Code into TextEdit and everything is fine. Then I can copy from TextEdit and paste into Teams and everything is fine.

      Anyone have a firm understanding of how the clipboard works and what app might be working incorrectly? Seems perhaps Teams is confused by meta data from Visual Studio Code?
      • my-kl's avatar
        my-kl
        Brass Contributor
        Using this website I was able to examine the clipboard data from TextEdit and Visual Studio code.

        The text/plain entries look identical, but the text/html entries are radically different. That seems to be a clue.

Resources