Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 15 additions & 3 deletions rich/_log_render.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from datetime import datetime
from typing import Iterable, List, Optional, TYPE_CHECKING, Union, Callable
from pathlib import Path


from .text import Text, TextType
Expand Down Expand Up @@ -71,15 +72,26 @@ def __call__(
row.append(Renderables(renderables))
if self.show_path and path:
path_text = Text()

uri = ""
if link_path:
try:
uri = Path(link_path).absolute().as_uri()
except ValueError:
uri = ""

path_text.append(
path, style=f"link file://{link_path}" if link_path else ""
path,
style=f"link {uri}" if uri else "",
)
if line_no:

if line_no is not None:
path_text.append(":")
path_text.append(
f"{line_no}",
style=f"link file://{link_path}#{line_no}" if link_path else "",
style=f"link {uri}#{line_no}" if uri else "",
)

row.append(path_text)

output.add_row(*row)
Expand Down