返回 DeepSeek-Reasonix
historical_source_mapping.go
根目录 / desktop / historical_source_mapping.go
1 package main
2
3 import (
4 "sort"
5 "strings"
6
7 "reasonix/desktop/internal/workspacestate"
8 )
9
10 func historicalSourceKeyMatches(mappingKey, sourceID string) bool {
11 return mappingKey == sourceID || strings.HasPrefix(mappingKey, sourceID+":review:")
12 }
13
14 func historicalMappingForSource(state workspacestate.State, sourceID string) (workspacestate.SourceMapping, bool, error) {
15 if mapping, ok, err := state.ResolveSource(sourceID); ok || err != nil {
16 return mapping, ok, err
17 }
18 keys := make([]string, 0, len(state.SourceMappings))
19 for key := range state.SourceMappings {
20 for _, alias := range state.SourceKeys(key) {
21 if historicalSourceKeyMatches(alias, sourceID) {
22 keys = append(keys, key)
23 break
24 }
25 }
26 }
27 sort.Strings(keys)
28 if len(keys) == 0 {
29 return workspacestate.SourceMapping{}, false, nil
30 }
31 return state.SourceMappings[keys[0]], true, nil
32 }
33
33 lines GO