about summary refs log tree commit diff
path: root/tests/rustdoc-js-std
diff options
context:
space:
mode:
authorMichael Howell <michael@notriddle.com>2023-03-10 18:18:43 -0700
committerMichael Howell <michael@notriddle.com>2023-03-10 19:47:08 -0700
commitdfd9e5e3fab422684f1768561e19869fbf5f6277 (patch)
tree95ab4ff63c57964f8e612e6f8119ee1e76a6243e /tests/rustdoc-js-std
parentff4b772f805ec1e1c1bd7e189ab8d5a4e3a6ef13 (diff)
downloadrust-dfd9e5e3fab422684f1768561e19869fbf5f6277.tar.gz
rust-dfd9e5e3fab422684f1768561e19869fbf5f6277.zip
rustdoc: use restricted Damerau-Levenshtein distance for search
Based on https://github.com/rust-lang/rust/pull/108200, for the same
rationale.

> This replaces the existing Levenshtein algorithm with the
> Damerau-Levenshtein algorithm. This means that "ab" to "ba" is one change
> (a transposition) instead of two (a deletion and insertion). More
> specifically, this is a restricted implementation, in that "ca" to "abc"
> cannot be performed as "ca" → "ac" → "abc", as there is an insertion in the
> middle of a transposition. I believe that errors like that are sufficiently
> rare that it's not worth taking into account.

Before this change, searching `prinltn!` listed `print!` first, followed
by `println!`. With this change, `println!` matches more closely.
Diffstat (limited to 'tests/rustdoc-js-std')
-rw-r--r--tests/rustdoc-js-std/println-typo.js12
1 files changed, 12 insertions, 0 deletions
diff --git a/tests/rustdoc-js-std/println-typo.js b/tests/rustdoc-js-std/println-typo.js
new file mode 100644
index 00000000000..7ca3ab8e563
--- /dev/null
+++ b/tests/rustdoc-js-std/println-typo.js
@@ -0,0 +1,12 @@
+// exact-check
+
+const QUERY = 'prinltn';
+const FILTER_CRATE = 'std';
+
+const EXPECTED = {
+    'others': [
+        { 'path': 'std', 'name': 'println' },
+        { 'path': 'std', 'name': 'print' },
+        { 'path': 'std', 'name': 'eprintln' },
+    ],
+};