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 22458a391..4fbbe3ddc 100644 --- a/editors/code/src/highlighting.ts +++ b/editors/code/src/highlighting.ts | |||
@@ -71,7 +71,7 @@ interface Decoration { | |||
71 | 71 | ||
72 | // Based on this HSL-based color generator: https://gist.github.com/bendc/76c48ce53299e6078a76 | 72 | // Based on this HSL-based color generator: https://gist.github.com/bendc/76c48ce53299e6078a76 |
73 | function fancify(seed: string, shade: 'light' | 'dark') { | 73 | function fancify(seed: string, shade: 'light' | 'dark') { |
74 | const random = randomU32Numbers(hashString(seed)) | 74 | const random = randomU32Numbers(hashString(seed)); |
75 | const randomInt = (min: number, max: number) => { | 75 | const randomInt = (min: number, max: number) => { |
76 | return Math.abs(random()) % (max - min + 1) + min; | 76 | return Math.abs(random()) % (max - min + 1) + min; |
77 | }; | 77 | }; |
@@ -255,14 +255,14 @@ function randomU32Numbers(seed: number) { | |||
255 | random ^= random >> 17; | 255 | random ^= random >> 17; |
256 | random ^= random << 5; | 256 | random ^= random << 5; |
257 | random |= 0; | 257 | random |= 0; |
258 | return random | 258 | return random; |
259 | } | 259 | }; |
260 | } | 260 | } |
261 | 261 | ||
262 | function hashString(str: string): number { | 262 | function hashString(str: string): number { |
263 | let res = 0; | 263 | let res = 0; |
264 | for (let i = 0; i < str.length; ++i) { | 264 | for (let i = 0; i < str.length; ++i) { |
265 | const c = str.codePointAt(i)!!; | 265 | const c = str.codePointAt(i)!; |
266 | res = (res * 31 + c) & ~0; | 266 | res = (res * 31 + c) & ~0; |
267 | } | 267 | } |
268 | return res; | 268 | return res; |