mirror of
https://github.com/astral-sh/ruff.git
synced 2025-09-29 05:15:12 +00:00
Sort messages prior to display (#56)
This commit is contained in:
parent
3afedcd48b
commit
0ebed13e67
2 changed files with 19 additions and 1 deletions
|
@ -1,3 +1,4 @@
|
|||
use std::cmp::Ordering;
|
||||
use std::fmt;
|
||||
|
||||
use colored::Colorize;
|
||||
|
@ -29,6 +30,22 @@ pub struct Message {
|
|||
pub filename: String,
|
||||
}
|
||||
|
||||
impl Ord for Message {
|
||||
fn cmp(&self, other: &Self) -> Ordering {
|
||||
(&self.filename, self.location.row(), self.location.column()).cmp(&(
|
||||
&other.filename,
|
||||
other.location.row(),
|
||||
self.location.column(),
|
||||
))
|
||||
}
|
||||
}
|
||||
|
||||
impl PartialOrd for Message {
|
||||
fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
|
||||
Some(self.cmp(other))
|
||||
}
|
||||
}
|
||||
|
||||
impl fmt::Display for Message {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
write!(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue