Skip to content

Commit

Permalink
Monaco Cursor Bug (#2922)
Browse files Browse the repository at this point in the history
  • Loading branch information
jameskerr authored Dec 9, 2023
1 parent 6866807 commit 7da28bd
Show file tree
Hide file tree
Showing 6 changed files with 194 additions and 189 deletions.
2 changes: 1 addition & 1 deletion apps/zui/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ module.exports = {
setupFiles: ["./src/test/unit/setup/before-env.ts"],
setupFilesAfterEnv: ["./src/test/unit/setup/after-env.ts"],
testEnvironmentOptions: {
testURL: "http://localhost:3000/?name=search&id=test-1",
testURL: "http://localhost:4567/?name=search&id=test-1",
},
globalSetup: "./src/test/unit/setup/global.ts",
modulePaths: ["<rootDir>"],
Expand Down
2 changes: 1 addition & 1 deletion apps/zui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"scripts": {
"start": "node scripts/start",
"start:main": "yarn build:main --watch",
"start:renderer": "next dev",
"start:renderer": "next dev -p 4567",
"start:electron": "nodemon --watch dist ../../node_modules/electron/cli.js .",
"watch-code": "run-p start:main start:renderer",
"build": "run-p -l 'build:**'",
Expand Down
185 changes: 185 additions & 0 deletions apps/zui/src/core/zed-syntax.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,185 @@
const primitiveTypes = [
"uint8",
"uint16",
"uint32",
"uint64",
"int8",
"int16",
"int32",
"int64",
"float16",
"float32",
"float64",
"bool",
"string",
"duration",
"time",
"bytes",
"ip",
"net",
"type",
"null",
]

const keywords = ["this", "const", "from", "file", "func", "op", "type"]

const builtinOps = [
"assert",
"combine",
"cut",
"drop",
"file",
"fork",
"from",
"fuse",
"get",
"head",
"join",
"load",
"merge",
"over",
"pass",
"put",
"rename",
"sample",
"search",
"sort",
"summarize",
"switch",
"tail",
"uniq",
"where",
"yield",
]

const builtinFuncs = [
"abs",
"base64",
"bucket",
"cast",
"ceil",
"cidr_match",
"compare",
"coalesce",
"crop",
"error",
"every",
"fields",
"fill",
"flatten",
"floor",
"grep",
"has",
"hex",
"has_error",
"is",
"is_error",
"join",
"kind",
"ksuid",
"len",
"levenshtein",
"log",
"lower",
"missing",
"nameof",
"nest_dotted",
"network_of",
"now",
"order",
"parse_uri",
"parse_zson",
"pow",
"quiet",
"regexp",
"regexp_replace",
"replace",
"round",
"rune_len",
"shape",
"split",
"sqrt",
"trim",
"typename",
"typeof",
"typeunder",
"under",
"unflatten",
"upper",
]

const builtinAggFuncs = [
"AND",
"OR",
"and",
"any",
"avg",
"collect",
"count",
"dcount",
"fuse",
"map",
"max",
"min",
"or",
"sum",
"union",
]

const operators = ["+", "-", "*", "/", ">", ">=", "<", "<=", "=", ":="]

const symbols = /[+\-*/><=:]+/

const identifier = /[a-zA-Z][\w$]*/

const identifierRule = [
identifier,
{
cases: {
"@keywords": "keyword",
"@builtinOps": "keyword",
"@builtinFuncs": "keyword",
"@builtinAggFuncs": "keyword",
"@primitiveTypes": "keyword",
"@operators": "operators",
"@default": "variable",
},
},
]

const operatorRule = [
symbols,
{
cases: {
"@operators": "operator",
"#default": "",
},
},
]

const integerRule = [/\d+/, "number"]
const floatRule = [/\d*\.\d+/, "number.float"]
const stringRule = [/("[^"]*")|('[^']*')/, "string"]
const commentRule = [/\/\/.*/, "comment"]
const bracketRule = [/[{}()[]]/, "@brackets"]

export const tokens = {
keywords,
operators,
primitiveTypes,
builtinAggFuncs,
builtinFuncs,
builtinOps,
symbols,
tokenizer: {
root: [
identifierRule,
commentRule,
bracketRule,
operatorRule,
integerRule,
floatRule,
stringRule,
] as any,
},
}
Empty file.
2 changes: 1 addition & 1 deletion apps/zui/src/electron/windows/zui-window.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ export abstract class ZuiWindow {
load() {
this.beforeLoad()
const url = env.isDevelopment
? `http://localhost:3000${this.path}?id=${this.id}&name=${this.name}`
? `http://localhost:4567${this.path}?id=${this.id}&name=${this.name}`
: `file://${this.path}.html?id=${this.id}&name=${this.name}`
return this.ref.loadURL(url)
}
Expand Down
Loading

0 comments on commit 7da28bd

Please sign in to comment.