chore: generate
This commit is contained in:
@@ -38,7 +38,9 @@ export async function resolveZedSelection(dbPath: string, cwd = process.cwd()):
|
|||||||
const text =
|
const text =
|
||||||
contents.type === "contents" && contents.contents != null
|
contents.type === "contents" && contents.contents != null
|
||||||
? contents.contents
|
? contents.contents
|
||||||
: await Bun.file(row.buffer_path).text().catch(() => undefined)
|
: await Bun.file(row.buffer_path)
|
||||||
|
.text()
|
||||||
|
.catch(() => undefined)
|
||||||
if (text == null) return { type: "unavailable" }
|
if (text == null) return { type: "unavailable" }
|
||||||
|
|
||||||
const startOffset = Math.min(row.selection_start, row.selection_end)
|
const startOffset = Math.min(row.selection_start, row.selection_end)
|
||||||
@@ -79,11 +81,10 @@ function queryZedActiveEditor(dbPath: string, cwd: string) {
|
|||||||
)
|
)
|
||||||
.all()
|
.all()
|
||||||
|
|
||||||
const rows = raw
|
const rows = raw.flatMap((row) => {
|
||||||
.flatMap((row) => {
|
const parsed = ZedEditorRowSchema.safeParse(row)
|
||||||
const parsed = ZedEditorRowSchema.safeParse(row)
|
return parsed.success ? [parsed.data] : []
|
||||||
return parsed.success ? [parsed.data] : []
|
})
|
||||||
})
|
|
||||||
|
|
||||||
if (raw.length > 0 && rows.length === 0) return { type: "unavailable" as const }
|
if (raw.length > 0 && rows.length === 0) return { type: "unavailable" as const }
|
||||||
|
|
||||||
|
|||||||
@@ -25,13 +25,10 @@ async function writeZedFixture(dir: string, options: ZedFixtureOptions = {}) {
|
|||||||
db.run("insert into panes values (1, 1, 1)")
|
db.run("insert into panes values (1, 1, 1)")
|
||||||
db.run("insert into items values (1, 1, 1, 1, 'Editor')")
|
db.run("insert into items values (1, 1, 1, 1, 'Editor')")
|
||||||
db.run("insert into editors values (1, 1, ?, ?)", [filePath, "one\ntwo\nthree"])
|
db.run("insert into editors values (1, 1, ?, ?)", [filePath, "one\ntwo\nthree"])
|
||||||
db.run(
|
db.run("insert into editor_selections values (1, 1, ?, ?)", [
|
||||||
"insert into editor_selections values (1, 1, ?, ?)",
|
options.selectionStart === undefined ? 4 : options.selectionStart,
|
||||||
[
|
options.selectionEnd === undefined ? 7 : options.selectionEnd,
|
||||||
options.selectionStart === undefined ? 4 : options.selectionStart,
|
])
|
||||||
options.selectionEnd === undefined ? 7 : options.selectionEnd,
|
|
||||||
],
|
|
||||||
)
|
|
||||||
db.close()
|
db.close()
|
||||||
|
|
||||||
return { dbPath, filePath }
|
return { dbPath, filePath }
|
||||||
|
|||||||
Reference in New Issue
Block a user