diff options
Diffstat (limited to 'editors/code/src/highlighting.ts')
-rw-r--r-- | editors/code/src/highlighting.ts | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/editors/code/src/highlighting.ts b/editors/code/src/highlighting.ts index 66216e0fc..e90fb8acc 100644 --- a/editors/code/src/highlighting.ts +++ b/editors/code/src/highlighting.ts | |||
@@ -69,7 +69,7 @@ interface Decoration { | |||
69 | 69 | ||
70 | // Based on this HSL-based color generator: https://gist.github.com/bendc/76c48ce53299e6078a76 | 70 | // Based on this HSL-based color generator: https://gist.github.com/bendc/76c48ce53299e6078a76 |
71 | function fancify(seed: string, shade: 'light' | 'dark') { | 71 | function fancify(seed: string, shade: 'light' | 'dark') { |
72 | const random = randomU32Numbers(hashString(seed)) | 72 | const random = randomU32Numbers(hashString(seed)); |
73 | const randomInt = (min: number, max: number) => { | 73 | const randomInt = (min: number, max: number) => { |
74 | return Math.abs(random()) % (max - min + 1) + min; | 74 | return Math.abs(random()) % (max - min + 1) + min; |
75 | }; | 75 | }; |
@@ -253,14 +253,14 @@ function randomU32Numbers(seed: number) { | |||
253 | random ^= random >> 17; | 253 | random ^= random >> 17; |
254 | random ^= random << 5; | 254 | random ^= random << 5; |
255 | random |= 0; | 255 | random |= 0; |
256 | return random | 256 | return random; |
257 | } | 257 | }; |
258 | } | 258 | } |
259 | 259 | ||
260 | function hashString(str: string): number { | 260 | function hashString(str: string): number { |
261 | let res = 0; | 261 | let res = 0; |
262 | for (let i = 0; i < str.length; ++i) { | 262 | for (let i = 0; i < str.length; ++i) { |
263 | const c = str.codePointAt(i)!!; | 263 | const c = str.codePointAt(i)!; |
264 | res = (res * 31 + c) & ~0; | 264 | res = (res * 31 + c) & ~0; |
265 | } | 265 | } |
266 | return res; | 266 | return res; |