I suggest you ...

Code snippet with preview

It would be really nice to have preview boxes of long code blocks (Code snippets).
It should be cropped if there are more then x lines (maybe configurable), and could be opened in a new tab or fade out within the chat. An extra code viewer "window" would be nice.

E.g. :
https://i.imgur.com/6I25yR1.png

It is really easy to do so:
Add a span/div element within the code block, give it absolute bottom position and a height (50px here), give it a gradient bg color and give the code block a max-height with overflow hidden. there you go.

49 votes
Vote
Sign in
(thinking…)
Sign in with: facebook google
Signed in as (Sign out)
You have left! (?) (thinking…)
Anonymous shared this idea  ·   ·  Flag idea as inappropriate…  ·  Admin →

10 comments

Sign in
(thinking…)
Sign in with: facebook google
Signed in as (Sign out)
Submitting...
  • Anonymous commented  ·   ·  Flag as inappropriate

    According to the documentation the existing code blocks should generate line numbers. They don't. This is one feature that would be an essential component of Code Snippets.

  • Nate R. commented  ·   ·  Flag as inappropriate

    This would be immensely helpful; I find myself sending log files (many times daily) for collaborating on bug fixing. First, I end up truncating out a bunch of potentially relevant information to take it down to 4000 characters. Second, even when it is 4000 characters, it ends up taking up all of the conversation window which is distracting and can derail other conversations which are going on in the same channel.

  • Ariel Balter commented  ·   ·  Flag as inappropriate

    I see that this is labeled "won't fix." If I understand the question, it is to replicate the "code snippet" feature in slack. I think that is a very important feature to clone, and should be on the map, not in "won't fix."

  • Josue Rivera commented  ·   ·  Flag as inappropriate

    Can this be submitted as a UX improvement to the code format render? For example if code is larger than x lines it gets truncated in to a in to a 2 or 3 line snippet with a preview click? I'm not talking about a new feature, but improving on the markdown method already implemented. This would make it easier to share big chunks of code without needed to writing it to a external editor and sharing a file. Unless they could consider a internal txt editor?

  • Anonymous commented  ·   ·  Flag as inappropriate

    I would, If I would have time. At the moment, this is not the case - sorry for that. But maybe I can have a look in ~2 Weeks

  • Anonymous commented  ·   ·  Flag as inappropriate

    I am not quite sure if I am to stupid, or you missunderstood me.
    I am running mattermost 2.1 and when I add a code block like

    ```ruby

    [lots of lines of code]

    ```

    i'll get a post where I can see all the lines of code.
    But what I am requesting is that the code preview gets cropped after some lines and can be fully viewed in an extra window or whatever.

Feedback and Knowledge Base