This repository was archived by the owner on Mar 27, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +11
-0
lines changed Expand file tree Collapse file tree 2 files changed +11
-0
lines changed Original file line number Diff line number Diff line change 11package gparselib
22
33import (
4+ "cmp"
45 "errors"
56 "fmt"
7+ "slices"
68 "strconv"
79 "strings"
810)
@@ -126,6 +128,13 @@ func (pd *ParseData) CleanFeedback(cleanEnd bool) {
126128// GetFeedback returns parser errors as a single error and
127129// additional feedback.
128130func (pd * ParseData ) GetFeedback () (string , error ) {
131+ slices .SortFunc (pd .Result .Feedback , func (a , b * FeedbackItem ) int {
132+ if n := cmp .Compare (a .Pos , b .Pos ); n != 0 {
133+ return n
134+ }
135+ // If positions are equal, order by message
136+ return strings .Compare (a .Msg .String (), b .Msg .String ())
137+ })
129138 return feedbackInfo (pd .Result ), feedbackError (pd .Result )
130139}
131140func feedbackError (pr * ParseResult ) error {
Original file line number Diff line number Diff line change @@ -334,9 +334,11 @@ func TestGetFeedback(t *testing.T) {
334334 Kind : FeedbackError ,
335335 Msg : & parseError {myErr : "err 2" },
336336 }, {
337+ Pos : 1 ,
337338 Kind : FeedbackWarning ,
338339 Msg : & parseMessage {msg : "warn 2" },
339340 }, {
341+ Pos : 2 ,
340342 Kind : FeedbackInfo ,
341343 Msg : & parseMessage {msg : "info 2" },
342344 },
You can’t perform that action at this time.
0 commit comments