@@ -104,7 +104,13 @@ namespace detail {
104
104
constexpr std::size_t margin_width = 8 ;
105
105
106
106
// 1-indexed line
107
- std::string get_snippet (const std::string& path, std::size_t target_line, std::size_t context_size, bool color) {
107
+ std::string get_snippet (
108
+ const std::string& path,
109
+ std::size_t target_line,
110
+ nullable<std::uint32_t > column,
111
+ std::size_t context_size,
112
+ bool color
113
+ ) {
108
114
const auto & manager = get_manager (path);
109
115
if (!manager.ok ()) {
110
116
return " " ;
@@ -126,15 +132,35 @@ namespace detail {
126
132
// make the snippet
127
133
std::string snippet;
128
134
for (auto line = begin; line <= end; line++) {
129
- if (color && line == target_line) {
130
- snippet += YELLOW;
131
- }
132
135
auto line_str = std::to_string (line);
133
- snippet += microfmt::format (" {>{}}: " , margin_width, line_str);
134
- if (color && line == target_line) {
135
- snippet += RESET;
136
+ if (line == target_line) {
137
+ if (color) {
138
+ snippet += YELLOW;
139
+ }
140
+ auto line_width = line_str.size () + 3 ;
141
+ snippet += microfmt::format (
142
+ " {>{}} > {}: " ,
143
+ line_width > margin_width ? 0 : margin_width - line_width,
144
+ " " ,
145
+ line_str
146
+ );
147
+ if (color) {
148
+ snippet += RESET;
149
+ }
150
+ } else {
151
+ snippet += microfmt::format (" {>{}}: " , margin_width, line_str);
136
152
}
137
153
snippet += lines[line - original_begin];
154
+ if (line == target_line && column.has_value ()) {
155
+ snippet += microfmt::format (" \n {>{}}" , margin_width + 2 + column.value () - 1 , " " );
156
+ if (color) {
157
+ snippet += YELLOW;
158
+ }
159
+ snippet += " ^" ;
160
+ if (color) {
161
+ snippet += RESET;
162
+ }
163
+ }
138
164
if (line != end) {
139
165
snippet += ' \n ' ;
140
166
}
0 commit comments