| 1 | # Changelog |
| 2 | |
| 3 | All notable changes to this project will be documented in this file. |
| 4 | |
| 5 | The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), |
| 6 | and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). |
| 7 | |
| 8 | ## [Unreleased] |
| 9 | |
| 10 | The minimum supported rustc version is now `1.67.0` (was `1.40.0`). |
| 11 | This is because some dependencies now require this Rust version. |
| 12 | |
| 13 | ### Added |
| 14 | |
| 15 | - Add the option to display a configurable amount of lines in front of and after any label. |
| 16 | - The `Severity` enum now implements full `Ord`. (#335) |
| 17 | |
| 18 | ### Changed |
| 19 | |
| 20 | - Broken lines are now rendered properly with multiline spans. |
| 21 | |
| 22 | We used to render the wrong lines in the gutter when there were multiline spans |
| 23 | and there were breaks in the file. |
| 24 | |
| 25 | <details> |
| 26 | <summary>Example</summary> |
| 27 | |
| 28 | Before: |
| 29 | |
| 30 | ```text |
| 31 | error[0001]: oh noes, a cupcake has occurred! |
| 32 | ┌─ test:4:1 |
| 33 | │ |
| 34 | 4 │ ╭ Cupcake ipsum dolor. Sit amet marshmallow topping cheesecake |
| 35 | 5 │ │ muffin. Halvah croissant candy canes bonbon candy. Apple pie jelly |
| 36 | │ ╭─│─────────' |
| 37 | · │ |
| 38 | 10 │ │ │ Muffin danish chocolate soufflé pastry icing bonbon oat cake. |
| 39 | 11 │ │ │ Powder cake jujubes oat cake. Lemon drops tootsie roll marshmallow |
| 40 | │ │ ╰─────────────────────────────' blah blah |
| 41 | · │ │ |
| 42 | 19 │ │ soufflé marzipan. Chocolate bar oat cake jujubes lollipop pastry |
| 43 | 20 │ │ cupcake. Candy canes cupcake toffee gingerbread candy canes muffin |
| 44 | │ ╰──────────' blah blah |
| 45 | ``` |
| 46 | |
| 47 | After: |
| 48 | |
| 49 | ```text |
| 50 | error[0001]: oh noes, a cupcake has occurred! |
| 51 | ┌─ test:4:1 |
| 52 | │ |
| 53 | 4 │ ╭ Cupcake ipsum dolor. Sit amet marshmallow topping cheesecake |
| 54 | 5 │ │ muffin. Halvah croissant candy canes bonbon candy. Apple pie jelly |
| 55 | │ ╭─│─────────' |
| 56 | · │ │ |
| 57 | 10 │ │ │ Muffin danish chocolate soufflé pastry icing bonbon oat cake. |
| 58 | 11 │ │ │ Powder cake jujubes oat cake. Lemon drops tootsie roll marshmallow |
| 59 | │ │ ╰─────────────────────────────' blah blah |
| 60 | · │ |
| 61 | 19 │ │ soufflé marzipan. Chocolate bar oat cake jujubes lollipop pastry |
| 62 | 20 │ │ cupcake. Candy canes cupcake toffee gingerbread candy canes muffin |
| 63 | │ ╰──────────' blah blah |
| 64 | ``` |
| 65 | |
| 66 | </details> |
| 67 | |
| 68 | ## [0.11.1] - 2021-01-18 |
| 69 | |
| 70 | ### Added |
| 71 | |
| 72 | - Add `Chars::{box_drawing, ascii}` functions, the latter supporting a rustc-style of |
| 73 | output that only uses ASCII characters (not above U+007F) for use cases that do not allow |
| 74 | for box drawing characters, e.g. terminals that do not support them. |
| 75 | |
| 76 | ### Changed |
| 77 | |
| 78 | - `Diagnostic::with_labels` and `Diagnostic::with_notes` now append additional |
| 79 | labels rather tan overwriting them, meaning that the documentation and behaviour match |
| 80 | more closely. The behaviour will only differ if you call the same builder methods |
| 81 | multiple times. If you call every builder method once only, nothing should change. |
| 82 | - `config::Chars::snippet_start` is now a String instead of a single `char`. |
| 83 | |
| 84 | ## [0.11.0] - 2020-11-30 |
| 85 | |
| 86 | There is now a [code of conduct](https://github.com/brendanzab/codespan/blob/master/CODE_OF_CONDUCT.md) |
| 87 | and a [contributing guide](https://github.com/brendanzab/codespan/blob/master/CONTRIBUTING.md). |
| 88 | |
| 89 | Some versions were skipped to sync up with the `codespan-lsp` crate. The release |
| 90 | process has been changed so this should not happen again. |
| 91 | |
| 92 | ### Added |
| 93 | |
| 94 | - If a label spans over multiple lines, not all lines are rendered. |
| 95 | The number of lines rendered at beginning and end is configurable separately. |
| 96 | - There is now a custom error type. |
| 97 | - There now is a medium rendering mode that is like the short rendering mode |
| 98 | but also shows notes from the diagnostic. |
| 99 | - `PartialEq` and `Eq` implementations for the `diagnostic::{Diagnostic, Label, Severity}` types. |
| 100 | |
| 101 | ### Changed |
| 102 | |
| 103 | - All errors now use the error type `codespan_reporting::file::Error`. |
| 104 | This type also replaces the custom error type for `codespan-lsp`. |
| 105 | |
| 106 | ### Fixed |
| 107 | |
| 108 | - Empty error codes are not rendered. |
| 109 | - The locus ("location of the diagnostic") is now computed so it is always at the first |
| 110 | primary label, or at the first secondary label if no primary labels are available. |
| 111 | - All `unwrap`s outside of tests and examples have been removed. |
| 112 | - Some internal improvements, including various code style improvements by using Clippy. |
| 113 | - Improved documentation, also mentioning how the ordering of labels is handled. |
| 114 | |
| 115 | ## [0.9.5] - 2020-06-24 |
| 116 | |
| 117 | ### Changed |
| 118 | |
| 119 | - Sections of source code that are marked with primary labels are now rendered |
| 120 | using the primary highlight color. |
| 121 | - Tab stops are now rendered properly. |
| 122 | |
| 123 | We used to just render `\t` characters in source snippets with the same |
| 124 | number of spaces. |
| 125 | |
| 126 | <details> |
| 127 | <summary>Example</summary> |
| 128 | |
| 129 | For example, when rendering with a tab width of `3` we |
| 130 | would print: |
| 131 | |
| 132 | ```text |
| 133 | warning: tab test |
| 134 | ┌─ tab_columns:1:2 |
| 135 | │ |
| 136 | 1 │ hello |
| 137 | │ ^^^^^ |
| 138 | 2 │ ∙ hello |
| 139 | │ ^^^^^ |
| 140 | 3 │ ∙∙ hello |
| 141 | │ ^^^^^ |
| 142 | 4 │ ∙∙∙ hello |
| 143 | │ ^^^^^ |
| 144 | 5 │ ∙∙∙∙ hello |
| 145 | │ ^^^^^ |
| 146 | 6 │ ∙∙∙∙∙ hello |
| 147 | │ ^^^^^ |
| 148 | 7 │ ∙∙∙∙∙∙ hello |
| 149 | │ ^^^^^ |
| 150 | ``` |
| 151 | |
| 152 | Now we properly take into account the column of the tab character: |
| 153 | |
| 154 | ```text |
| 155 | warning: tab test |
| 156 | ┌─ tab_columns:1:2 |
| 157 | │ |
| 158 | 1 │ hello |
| 159 | │ ^^^^^ |
| 160 | 2 │ ∙ hello |
| 161 | │ ^^^^^ |
| 162 | 3 │ ∙∙ hello |
| 163 | │ ^^^^^ |
| 164 | 4 │ ∙∙∙ hello |
| 165 | │ ^^^^^ |
| 166 | 5 │ ∙∙∙∙ hello |
| 167 | │ ^^^^^ |
| 168 | 6 │ ∙∙∙∙∙ hello |
| 169 | │ ^^^^^ |
| 170 | 7 │ ∙∙∙∙∙∙ hello |
| 171 | │ ^^^^^ |
| 172 | ``` |
| 173 | |
| 174 | </details> |
| 175 | |
| 176 | ## [0.9.4] - 2020-05-18 |
| 177 | |
| 178 | ### Changed |
| 179 | |
| 180 | - We have made the caret rendering easier to read when there are multiple |
| 181 | labels on the same line. We also avoid printing trailing borders on the |
| 182 | final source source snippet if no notes are present. |
| 183 | |
| 184 | <details> |
| 185 | <summary>Example</summary> |
| 186 | |
| 187 | Instead of this: |
| 188 | |
| 189 | ```text |
| 190 | ┌─ one_line.rs:3:5 |
| 191 | │ |
| 192 | 3 │ v.push(v.pop().unwrap()); |
| 193 | │ - first borrow later used by call |
| 194 | │ ---- first mutable borrow occurs here |
| 195 | │ ^ second mutable borrow occurs here |
| 196 | │ |
| 197 | ``` |
| 198 | |
| 199 | …we now render the following: |
| 200 | |
| 201 | ```text |
| 202 | ┌─ one_line.rs:3:5 |
| 203 | │ |
| 204 | 3 │ v.push(v.pop().unwrap()); |
| 205 | │ - ---- ^ second mutable borrow occurs here |
| 206 | │ │ │ |
| 207 | │ │ first mutable borrow occurs here |
| 208 | │ first borrow later used by call |
| 209 | ``` |
| 210 | |
| 211 | </details> |
| 212 | |
| 213 | ### Fixed |
| 214 | |
| 215 | - Diagnostic rendering no longer panics if label ranges are between UTF-8 |
| 216 | character boundaries. |
| 217 | |
| 218 | ## [0.9.3] - 2020-04-29 |
| 219 | |
| 220 | ### Changed |
| 221 | |
| 222 | - Some panics were fixed when invalid unicode boundaries are supplied. |
| 223 | - Labels that marked the same span were originally rendered in reverse order. |
| 224 | This was a mistake! We've now fixed this. |
| 225 | |
| 226 | <details> |
| 227 | <summary>Example</summary> |
| 228 | |
| 229 | For example, this diagnostic: |
| 230 | |
| 231 | ```text |
| 232 | ┌─ same_range:1:7 |
| 233 | │ |
| 234 | 1 │ ::S { } |
| 235 | │ - Expected '(' |
| 236 | │ ^ Unexpected '{' |
| 237 | │ |
| 238 | ``` |
| 239 | |
| 240 | …will now be rendered as: |
| 241 | |
| 242 | ```text |
| 243 | ┌─ same_range:1:7 |
| 244 | │ |
| 245 | 1 │ ::S { } |
| 246 | │ ^ Unexpected '{' |
| 247 | │ - Expected '(' |
| 248 | │ |
| 249 | ``` |
| 250 | |
| 251 | </details> |
| 252 | |
| 253 | - We've reduced the prominence of the 'locus' on source snippets by |
| 254 | simplifying the border and reducing the spacing around it. This is to help |
| 255 | focus attention on the underlined source snippet and error messages, rather |
| 256 | than the location, which should be a secondary focus. |
| 257 | |
| 258 | <details> |
| 259 | <summary>Example</summary> |
| 260 | |
| 261 | For example we originally rendered this: |
| 262 | |
| 263 | ```text |
| 264 | error: unknown builtin: `NATRAL` |
| 265 | |
| 266 | ┌── Data/Nat.fun:7:13 ─── |
| 267 | │ |
| 268 | 7 │ {-# BUILTIN NATRAL Nat #-} |
| 269 | │ ^^^^^^ unknown builtin |
| 270 | │ |
| 271 | = there is a builtin with a similar name: `NATURAL` |
| 272 | |
| 273 | ``` |
| 274 | |
| 275 | …and now we render this: |
| 276 | |
| 277 | ```text |
| 278 | error: unknown builtin: `NATRAL` |
| 279 | ┌─ Data/Nat.fun:7:13 |
| 280 | │ |
| 281 | 7 │ {-# BUILTIN NATRAL Nat #-} |
| 282 | │ ^^^^^^ unknown builtin |
| 283 | │ |
| 284 | = there is a builtin with a similar name: `NATURAL` |
| 285 | |
| 286 | ``` |
| 287 | |
| 288 | </details> |
| 289 | |
| 290 | ## [0.9.2] - 2020-03-29 |
| 291 | |
| 292 | ### Changed |
| 293 | |
| 294 | - Render overlapping multiline marks on the same lines of source code. |
| 295 | |
| 296 | <details> |
| 297 | <summary>Example</summary> |
| 298 | |
| 299 | For example: |
| 300 | |
| 301 | ```text |
| 302 | error[E0308]: match arms have incompatible types |
| 303 | |
| 304 | ┌── codespan/src/file.rs:1:9 ─── |
| 305 | │ |
| 306 | 1 │ ╭ match line_index.compare(self.last_line_index()) { |
| 307 | 2 │ │ Ordering::Less => Ok(self.line_starts()[line_index.to_usize()]), |
| 308 | 3 │ │ Ordering::Equal => Ok(self.source_span().end()), |
| 309 | 4 │ │ Ordering::Greater => LineIndexOutOfBoundsError { |
| 310 | 5 │ │ given: line_index, |
| 311 | 6 │ │ max: self.last_line_index(), |
| 312 | 7 │ │ }, |
| 313 | 8 │ │ } |
| 314 | │ ╰─────────' `match` arms have incompatible types |
| 315 | · |
| 316 | 2 │ Ordering::Less => Ok(self.line_starts()[line_index.to_usize()]), |
| 317 | │ --------------------------------------------- this is found to be of type `Result<ByteIndex, LineIndexOutOfBoundsError>` |
| 318 | 3 │ Ordering::Equal => Ok(self.source_span().end()), |
| 319 | │ ---------------------------- this is found to be of type `Result<ByteIndex, LineIndexOutOfBoundsError>` |
| 320 | 4 │ Ordering::Greater => LineIndexOutOfBoundsError { |
| 321 | │ ╭──────────────────────────────────^ |
| 322 | 5 │ │ given: line_index, |
| 323 | 6 │ │ max: self.last_line_index(), |
| 324 | 7 │ │ }, |
| 325 | │ ╰─────────────^ expected enum `Result`, found struct `LineIndexOutOfBoundsError` |
| 326 | │ |
| 327 | = expected type `Result<ByteIndex, LineIndexOutOfBoundsError>` |
| 328 | found type `LineIndexOutOfBoundsError` |
| 329 | ``` |
| 330 | |
| 331 | …is now rendered as: |
| 332 | |
| 333 | ```text |
| 334 | error[E0308]: match arms have incompatible types |
| 335 | |
| 336 | ┌── codespan/src/file.rs:1:9 ─── |
| 337 | │ |
| 338 | 1 │ ╭ match line_index.compare(self.last_line_index()) { |
| 339 | 2 │ │ Ordering::Less => Ok(self.line_starts()[line_index.to_usize()]), |
| 340 | │ │ --------------------------------------------- this is found to be of type `Result<ByteIndex, LineIndexOutOfBoundsError>` |
| 341 | 3 │ │ Ordering::Equal => Ok(self.source_span().end()), |
| 342 | │ │ ---------------------------- this is found to be of type `Result<ByteIndex, LineIndexOutOfBoundsError>` |
| 343 | 4 │ │ Ordering::Greater => LineIndexOutOfBoundsError { |
| 344 | │ ╭─│──────────────────────────────────^ |
| 345 | 5 │ │ │ given: line_index, |
| 346 | 6 │ │ │ max: self.last_line_index(), |
| 347 | 7 │ │ │ }, |
| 348 | │ ╰─│─────────────^ expected enum `Result`, found struct `LineIndexOutOfBoundsError` |
| 349 | 8 │ │ } |
| 350 | │ ╰─────────' `match` arms have incompatible types |
| 351 | │ |
| 352 | = expected type `Result<ByteIndex, LineIndexOutOfBoundsError>` |
| 353 | found type `LineIndexOutOfBoundsError` |
| 354 | ``` |
| 355 | |
| 356 | </details> |
| 357 | |
| 358 | ## [0.9.1] - 2020-03-23 |
| 359 | |
| 360 | ### Added |
| 361 | |
| 362 | - `codespan_reporting::diagnostic::Diagnostic` now implements `Debug`. |
| 363 | |
| 364 | ### Changed |
| 365 | |
| 366 | - Single-line labels are now rendered together, under the same source line. |
| 367 | |
| 368 | <details> |
| 369 | <summary>Example</summary> |
| 370 | |
| 371 | For example: |
| 372 | |
| 373 | ```text |
| 374 | ┌── one_line.rs:3:5 ─── |
| 375 | │ |
| 376 | 3 │ v.push(v.pop().unwrap()); |
| 377 | │ - first borrow later used by call |
| 378 | · |
| 379 | 3 │ v.push(v.pop().unwrap()); |
| 380 | │ ---- first mutable borrow occurs here |
| 381 | · |
| 382 | 3 │ v.push(v.pop().unwrap()); |
| 383 | │ ^ second mutable borrow occurs here |
| 384 | │ |
| 385 | ``` |
| 386 | |
| 387 | …is now rendered as: |
| 388 | |
| 389 | ```text |
| 390 | ┌── one_line.rs:3:5 ─── |
| 391 | │ |
| 392 | 3 │ v.push(v.pop().unwrap()); |
| 393 | │ - first borrow later used by call |
| 394 | │ ---- first mutable borrow occurs here |
| 395 | │ ^ second mutable borrow occurs here |
| 396 | │ |
| 397 | ``` |
| 398 | |
| 399 | </details> |
| 400 | |
| 401 | ## [0.9.0] - 2020-03-11 |
| 402 | |
| 403 | ### Added |
| 404 | |
| 405 | - The `codespan_reporting::files` module was added as a way to decouple |
| 406 | `codespan_reporting` from `codespan`. |
| 407 | - `codespan_reporting::files::Files` allows users to implement custom file |
| 408 | databases that work with `codespan_reporting`. This should make it |
| 409 | easier to integrate with libraries like Salsa, and also makes it less |
| 410 | invasive to use `codespan_reporting` on existing projects. |
| 411 | - `codespan_reporting::files::SimpleFile` is a simple implementation of |
| 412 | `codespan_reporting::files::Files` where only a single file is needed. |
| 413 | - `codespan_reporting::files::SimpleFiles` is a simple implementation of |
| 414 | `codespan_reporting::files::Files` where multiple files are needed. |
| 415 | |
| 416 | ### Changed |
| 417 | |
| 418 | - The `codespan_reporting::diagnostic` module has been greatly revamped, |
| 419 | making the builder API format more nicely with rustfmt, and allowing for |
| 420 | multiple primary labels. |
| 421 | - The output of `codespan_reporting::term::emit` was improved, |
| 422 | with the following changes: |
| 423 | - labels on consecutive lines no longer render breaks between them |
| 424 | - source lines are rendered when there is only one line between labels |
| 425 | - the inner gutter of code snippets is now aligned consistently |
| 426 | - the outer gutter of consecutive code snippets are now aligned consistently |
| 427 | - `codespan_reporting::term::emit` now takes writers as a trait object (rather |
| 428 | than using static dispatch) in order to reduce coda bloat and improve |
| 429 | compile times. |
| 430 | - The field names in `codespan_reporting::term::Chars` were tweaked for |
| 431 | consistency. |
| 432 | |
| 433 | ### Removed |
| 434 | |
| 435 | - `codespan_reporting` no longer depends on `codespan`. |
| 436 | Note that `codespan` can _still_ be used with `codespan_reporting`, |
| 437 | as `codespan::Files` now implements `codespan_reporting::files::Files`. |
| 438 | |
| 439 | ## [0.8.0] - 2020-02-24 |
| 440 | ## [0.7.0] - 2020-01-06 |
| 441 | ## [0.6.0] - 2019-12-18 |
| 442 | ## [0.5.0] - 2019-10-02 |
| 443 | ## [0.4.1] - 2019-08-25 |
| 444 | ## [0.4.0] - 2019-08-22 |
| 445 | ## [0.3.0] - 2019-05-01 |
| 446 | ## [0.2.1] - 2019-02-26 |
| 447 | ## [0.2.0] - 2018-10-11 |
| 448 | |
| 449 | [Unreleased]: https://github.com/brendanzab/codespan/compare/v0.11.1...HEAD |
| 450 | [0.11.1]: https://github.com/brendanzab/codespan/compare/v0.11.0..v0.11.1 |
| 451 | [0.11.0]: https://github.com/brendanzab/codespan/compare/v0.9.5...v0.11.0 |
| 452 | [0.9.5]: https://github.com/brendanzab/codespan/compare/v0.9.4...v0.9.5 |
| 453 | [0.9.4]: https://github.com/brendanzab/codespan/compare/v0.9.3...v0.9.4 |
| 454 | [0.9.3]: https://github.com/brendanzab/codespan/compare/v0.9.2...v0.9.3 |
| 455 | [0.9.2]: https://github.com/brendanzab/codespan/compare/v0.9.1...v0.9.2 |
| 456 | [0.9.1]: https://github.com/brendanzab/codespan/compare/v0.9.0...v0.9.1 |
| 457 | [0.9.0]: https://github.com/brendanzab/codespan/compare/v0.8.0...v0.9.0 |
| 458 | [0.8.0]: https://github.com/brendanzab/codespan/compare/v0.7.0...v0.8.0 |
| 459 | [0.7.0]: https://github.com/brendanzab/codespan/compare/v0.6.0...v0.7.0 |
| 460 | [0.6.0]: https://github.com/brendanzab/codespan/compare/v0.5.0...v0.6.0 |
| 461 | [0.5.0]: https://github.com/brendanzab/codespan/compare/v0.4.1...v0.5.0 |
| 462 | [0.4.1]: https://github.com/brendanzab/codespan/compare/v0.4.0...v0.4.1 |
| 463 | [0.4.0]: https://github.com/brendanzab/codespan/compare/v0.3.0...v0.4.0 |
| 464 | [0.3.0]: https://github.com/brendanzab/codespan/compare/v0.2.1...v0.3.0 |
| 465 | [0.2.1]: https://github.com/brendanzab/codespan/compare/v0.2.0...v0.2.1 |
| 466 | [0.2.0]: https://github.com/brendanzab/codespan/releases/tag/v0.2.0 |