microsoft / microsoft/AdaptiveCards

[Feature Request] CodeBlocks cannot disable line numbering

Open
#9,010 7 comments 12 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Request
Dominant language
C#
Stars
2k
Forks
595
Avg merge
1d 19h
Merged PRs (30d)
1

Description

Problem Statement

The line numbering in a CodeBlock is part of the selectable text, so if you copy and paste the code block, the line numbers come too. This is quite unhelpful for actually runnable code. Ideally it would both be possible to disable the line numbers, and when present they would not be copied and pasted along with the code.

For example:

image

Copies and pastes as:

9
-----------------------------
10
Total (no discount):   £32.86
11
Reduction:             £4.99
12
=============================
13
Total (with discount): £27.87
14
=============================
Proposed solution

Add a CodeBlock parameter to disable line numbering. When it's enabled, it should be non-selectable text. GitHub achieves this for line numbers, and there's a (different) pure CSS example here, and inline here.

Alternatives or Workarounds

Not using CodeBlocks, but I can't find an alternative that offers real monospaced preformatted text in Teams/AdaptiveCard.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by locating the CodeBlock entry point and its rendering implementations in the AdaptiveCards repository. Trace how line numbers are generated and copied, then define completion as a parameter that disables numbering and prevents displayed numbers from being included in copied code.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
frontend
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.