fix(app): prevent infinite loop in @-mention scan when @ is at index 0
`findActiveFileMention` walked back through `@` candidates with
`lastIndexOf("@", atIndex - 1)`, but per spec a negative `position`
clamps to 0 — so once `atIndex` hit 0 with an invalid query (e.g. a
trailing space), the loop stepped from 0 back to 0 forever, freezing
the JS thread on every keystroke and forcing a quit.
Refs #596, #425
This commit is contained in:
@@ -36,6 +36,14 @@ describe("findActiveFileMention", () => {
|
||||
});
|
||||
expect(mention).toBeNull();
|
||||
});
|
||||
|
||||
it("returns null when @ at start is followed by a delimiter", () => {
|
||||
const mention = findActiveFileMention({
|
||||
text: "@ ",
|
||||
cursorIndex: 2,
|
||||
});
|
||||
expect(mention).toBeNull();
|
||||
});
|
||||
});
|
||||
|
||||
describe("applyFileMentionReplacement", () => {
|
||||
|
||||
Reference in New Issue
Block a user