Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions src/editor/customMarkdownConverter.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1008,6 +1008,24 @@ describe("markdownToBlocks", () => {
expect(nestedChildren.some((child) => child.type === "bulletListItem")).toBe(true);
});

it("does not freeze on indented list items without a parent", () => {
const markdown = [
"### Requirements",
"",
" * The system should log in the user {{username}} with password ${password} successfully.",
"",
" ### Steps",
"",
" * Open login page",
" *Expected*: The main page is opened",
].join("\n");

const blocks = markdownToBlocks(markdown);
expect(blocks.length).toBeGreaterThan(0);
const bullets = blocks.filter((b) => b.type === "bulletListItem");
expect(bullets.length).toBeGreaterThanOrEqual(1);
});

it("parses expected result prefixes with emphasis", () => {
const markdown = [
"* Open the form.",
Expand Down
2 changes: 1 addition & 1 deletion src/editor/customMarkdownConverter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -796,7 +796,7 @@ function parseList(
// Check if this line should be parsed as nested content
// Only go deeper if indent is at least 2 more than the next level's expected indent
const nextLevelExpectedIndent = (indentLevel + 1) * 2;
if (indent >= nextLevelExpectedIndent) {
if (indent >= nextLevelExpectedIndent && items.length > 0) {
const lastItem = items.at(-1);
if (!lastItem) {
break;
Expand Down
11 changes: 5 additions & 6 deletions src/editor/snippetAutocomplete.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,13 @@ export function useSnippetAutocomplete(): SnippetSuggestion[] {
const [suggestions, setSuggestions] = useState<SnippetSuggestion[]>(() => {
if (cachedSuggestions.length > 0) return cachedSuggestions;
if (!globalFetcher) return [];
if (inflightPromise) return [];
const result = globalFetcher();
if (result && typeof (result as Promise<unknown>).then === "function") {
if (!inflightPromise) {
inflightPromise = (result as Promise<SnippetInput>)
.then((r) => normalizeSnippetSuggestions(r))
.then((items) => { cachedSuggestions = items; inflightPromise = null; return items; })
.catch((error) => { inflightPromise = null; console.error("Failed to fetch snippet suggestions", error); return [] as SnippetSuggestion[]; });
}
inflightPromise = (result as Promise<SnippetInput>)
.then((r) => normalizeSnippetSuggestions(r))
.then((items) => { cachedSuggestions = items; inflightPromise = null; return items; })
.catch((error) => { inflightPromise = null; console.error("Failed to fetch snippet suggestions", error); return [] as SnippetSuggestion[]; });
return [];
}
const normalized = normalizeSnippetSuggestions(result as SnippetInput);
Expand Down
11 changes: 5 additions & 6 deletions src/editor/stepAutocomplete.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,13 @@ export function useStepAutocomplete(): StepSuggestion[] {
const [suggestions, setSuggestions] = useState<StepSuggestion[]>(() => {
if (cachedSuggestions.length > 0) return cachedSuggestions;
if (!globalFetcher) return [];
if (inflightPromise) return [];
const result = globalFetcher();
if (result && typeof (result as Promise<unknown>).then === "function") {
if (!inflightPromise) {
inflightPromise = (result as Promise<StepInput>)
.then((r) => normalizeStepSuggestions(r))
.then((items) => { cachedSuggestions = items; inflightPromise = null; return items; })
.catch((error) => { inflightPromise = null; console.error("Failed to fetch step suggestions", error); return [] as StepSuggestion[]; });
}
inflightPromise = (result as Promise<StepInput>)
.then((r) => normalizeStepSuggestions(r))
.then((items) => { cachedSuggestions = items; inflightPromise = null; return items; })
.catch((error) => { inflightPromise = null; console.error("Failed to fetch step suggestions", error); return [] as StepSuggestion[]; });
return [];
}
const normalized = normalizeStepSuggestions(result as StepInput);
Expand Down
Loading