Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

Eliminate horizontal scrolling in rust code blocks

Đang mở
#2,012 18 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức phù hợp với người mới
35/100
Loại issue
Lỗi
Độ rõ ràng
Cần làm rõ
Mức độ hoạt động
Đình trệ
Công nghệ
markdown, rust
Lĩnh vực
documentation

Hướng nghiên cứu

Bắt đầu với rustfmt.toml và các khối mã Rust có thể chỉnh sửa được mô tả trong issue, sau đó so sánh các khối đã render với độ dài dòng và số lượng dòng khác nhau. Xem xét cách các tệp Rust được include, các chú thích đã dịch, các biểu thức use, macro, lệnh shell và đầu ra được xử lý. Việc hoàn tất cần bao gồm một phương án đã thống nhất để ngăn việc cuộn ngang và một bước xác thực, hoặc một quyết định được ghi lại cho các trường hợp còn lại.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

The style guide mentiones presentation use case for the course. That means much inconvenience while dealing with very long lines in the code snippets.

The problem was addressed earlier as it can be seen from rustfmt.toml configuration:

# The code blocks get a scrollbar if they are wider than this.
max_width = 85

This works well for read only blocks, but fails for editable ones. Due to line numbering, there is less space left for the code. My observations are that the scrolling threshold is 83 for less than 10 line long code, 82 - less than 100 and 81 - above 100. There are no snippets above 1k and I suppose there must not be in the context of the course.

The following merge request adopts max 81-character width and eliminates detected scrolling in rust code blocks.

I suppose it is a partial solution though. But further steps require a discussion.

There should be an automated format validation step. rustfmt can do so with rust files, but not markdown. Across the course there are examples where rust code is separated from markdown files and included like:

{{#include testing/src/lib.rs:leftpad}}

But. Firstly, that means all the rust code should be excluded from md files and guides updated. Secondly, rust code contains comments that are translated. And translations can turn out to be longer than the source. And the result should also be tested. Thirdly, rustfmt seems to ignore long use expressions and long strings in macro arguments - leaves them as they are without errors.

Also the course has some code blocks with long shell commands and text output. Were left unchanged.

Summary questions:

  • Should we exclude all rust code from markdown files?
  • How can we validate rust code with translated comments?
  • How to deal with use and macros arguments that can still produce horizontal scrolling?
  • What to do with other code blocks with very long lines?
Ngôn ngữ chính
Rust
Star
33.4k
Fork
2.1k
Merge trung bình
2 ngày 9 giờ
Pull request đã merge (30 ngày)
16

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của google/comprehensive-rust

Tất cả issue của google/comprehensive-rust

Issue tương tự

Thêm issue về Rust

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.