Skip to content

Commit e5c300d

Browse files
committed
fix background
1 parent 3509614 commit e5c300d

File tree

4 files changed

+21
-10
lines changed

4 files changed

+21
-10
lines changed

CHANGELOG.md

+6
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
## [0.8.8] - 2020-03-31
9+
10+
### Fixed
11+
12+
- Fixed background in Syntax
13+
814
## [0.8.7] - 2020-03-31
915

1016
### Fixed

pyproject.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
name = "rich"
33
homepage = "https://github.com/willmcgugan/rich"
44
documentation = "https://rich.readthedocs.io/en/latest/"
5-
version = "0.8.7"
5+
version = "0.8.8"
66
description = "Render rich text, tables, progress bars, syntax highlighting, markdown and more to the terminal"
77
authors = ["Will McGugan <[email protected]>"]
88
license = "MIT"

rich/syntax.py

+9-2
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,12 @@ def __console__(self, console: Console, options: ConsoleOptions) -> RenderResult
262262
line, render_options, style=background_style
263263
)
264264
else:
265-
wrapped_lines = [list(line.render(console, render_options, end=""))]
265+
segments = list(line.render(console, end=""))
266+
wrapped_lines = [
267+
Segment.adjust_line_length(
268+
segments, render_options.max_width, style=background_style
269+
)
270+
]
266271
for first, wrapped_line in loop_first(wrapped_lines):
267272
if first:
268273
line_column = str(line_no).rjust(numbers_column_width - 2) + " "
@@ -289,5 +294,7 @@ def __console__(self, console: Console, options: ConsoleOptions) -> RenderResult
289294

290295
console = Console()
291296

292-
syntax = Syntax.from_path(sys.argv[1], line_numbers=True, word_wrap=True)
297+
syntax = Syntax.from_path(
298+
sys.argv[1], line_numbers=True, word_wrap=False, theme="default"
299+
)
293300
console.print(syntax)

rich/text.py

+5-7
Original file line numberDiff line numberDiff line change
@@ -329,7 +329,7 @@ def __console__(
329329
tab_size=tab_size,
330330
)
331331
all_lines = Text("\n").join(lines)
332-
yield from all_lines.render(console, options, end=self.end)
332+
yield from all_lines.render(console, end=self.end)
333333

334334
def __measure__(self, console: "Console", max_width: int) -> Measurement:
335335
text = self.text
@@ -339,14 +339,12 @@ def __measure__(self, console: "Console", max_width: int) -> Measurement:
339339
min_text_width = max(cell_len(word) for word in text.split())
340340
return Measurement(min_text_width, max_text_width)
341341

342-
def render(
343-
self, console: "Console", options: "ConsoleOptions", end: str = None
344-
) -> Iterable["Segment"]:
345-
"""Render the rich text to the console.
342+
def render(self, console: "Console", end: str = None) -> Iterable["Segment"]:
343+
"""Render the text as Segments.
346344
347345
Args:
348-
console (Console): Console instance.
349-
options (ConsoleOptions): Console options.
346+
console (Console): Console instance.
347+
end (Optional[str], optional): Optional end character.
350348
351349
Returns:
352350
Iterable[Segment]: Result of render that may be written to the console.

0 commit comments

Comments
 (0)