1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
//! Ranking boosts for completion items.
//!
//! The editor scores a completion as its own match quality plus this boost, so these
//! values only decide between candidates that match comparably well — they never
//! promote a poor match over a good one. Match penalties are in the hundreds; these
//! are in the tens, deliberately.
//!
//! CodeMirror documents a ±99 range for boosts. Staying inside it is what keeps the
//! ladder a tiebreak rather than an override, so new tiers belong between the values
//! here rather than beyond them.
//!
//! The whole ladder lives here, in one place, so it can be read top to bottom and
//! imported from anywhere. A completion that carries no boost at all sits at an
//! effective `0` — that is the baseline functions and unrecognized namespaces share.
/// Pipeline definitions are declared in the query being written, so they outrank
/// anything that came from the catalog.
pub const PIPELINE_DEF_BOOST: i32 = 99;
/// Datasets with no namespace: the plainest names in the current space.
pub const BARE_DATASET_BOOST: i32 = 90;
/// Datasets under `events` or `events_ecs`.
pub const EVENTS_DATASET_BOOST: i32 = 60;
/// Datasets under `signals`.
pub const SIGNALS_DATASET_BOOST: i32 = 30;
/// Datasets under a namespace this ladder does not recognize.
pub const UNRECOGNIZED_DATASET_BOOST: i32 = 0;
/// Datasets under `connectors`, demoted below everything else (SIM-5588).
///
/// Negative rather than merely unboosted: sharing [`UNRECOGNIZED_DATASET_BOOST`] would
/// let a connector tie with a dataset in some other namespace and then win the
/// alphabetical tiebreak.
pub const CONNECTOR_DATASET_BOOST: i32 = -30;
/// Extra credit for a dataset in the query's default space.
///
/// Every space is a section, and sections are ranked dynamically: a section scores as the
/// best score of any member. On an empty pattern every candidate matches identically, so
/// every space ties and this is the only thing left to separate them. It never has to do
/// more than break an exact tie — which is why it is the smallest value on the ladder.
///
/// Note that this makes the current space a *preference*, not a guarantee: a space holding
/// a clearly better match outranks it, which is the point of SIM-5641. Because a section
/// takes the best score among its members, a current space whose best candidate is a
/// connector can lose to another space's bare dataset even on an empty pattern.
///
/// [`BARE_DATASET_BOOST`] plus this is exactly 99, the top of CodeMirror's documented
/// range, so the ladder is now at its ceiling. A tier above bare datasets means rescaling
/// the whole ladder rather than reaching past 99.
pub const CURRENT_SPACE_BOOST: i32 = 9;
/// Fields of the row being queried, which outrank functions when nothing else
/// separates them.
///
/// This replaces a section that used to partition fields from functions outright.
/// A boost keeps the same default order while letting a well-matched function win,
/// which a section could not (SIM-3255).
pub const FIELD_BOOST: i32 = 30;