mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-09-27 19:01:02 +00:00
Update translations. Code dedup and cleanup
This commit is contained in:
@@ -5,7 +5,7 @@ const vm = require("vm"), assert = require("assert"), fs = require("fs");
|
||||
const ctx = {};
|
||||
vm.createContext(ctx);
|
||||
vm.runInContext(fs.readFileSync(__dirname + "/fuzzy-search.js", "utf8"), ctx);
|
||||
const { FoldChar, Norm, NormText, EscapeRegExp, FuzzyRanges, WholeWordRanges, FuzzyRangesNorm, WholeWordRangesNorm } = ctx;
|
||||
const { FoldChar, Norm, NormText, EscapeRegExp, FuzzyRanges, WholeWordRanges, FuzzyRangesNorm } = ctx;
|
||||
|
||||
// FoldChar / Norm: accents fold, case only folds when case-insensitive.
|
||||
assert.equal(FoldChar("é"), "e");
|
||||
@@ -41,8 +41,11 @@ assert.deepEqual(FuzzyRangesNorm(NormText("Auto-Orient", false), NormText("orien
|
||||
assert.deepEqual(FuzzyRangesNorm(NormText("AutoOriented", false), NormText("orient", false)), [[4, 10]]);
|
||||
assert.equal(FuzzyRangesNorm(NormText("Measure", false), NormText("xyz", false)), null); // no subsequence
|
||||
|
||||
// WholeWordRangesNorm: \b-bounded literal against a pre-normalized haystack, offsets in original coords.
|
||||
assert.deepEqual(WholeWordRangesNorm(NormText("Auto-Orient", false), NormText("orient", false)), [[5, 11]]);
|
||||
assert.equal(WholeWordRangesNorm(NormText("AutoOriented", false), NormText("orient", false)), null); // inside a word
|
||||
// NormText stays 1:1 with the original even when NFD expands (Hangul syllables) or drops (combining
|
||||
// diacritics, U+0130) a code unit, so highlight ranges remain aligned to the original string.
|
||||
assert.equal(NormText("각x", false).length, "각x".length);
|
||||
assert.equal(NormText("e\u0301x", false).length, "e\u0301x".length);
|
||||
assert.equal(NormText("\u0130x", false).length, "\u0130x".length);
|
||||
assert.equal(FuzzyRangesNorm(NormText("각abcdeXfgh", false), NormText("X", false))[0][0], 6);
|
||||
|
||||
console.log("ok");
|
||||
|
||||
Reference in New Issue
Block a user