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