Skip to content

Commit

Permalink
Add some tests trying to expose #1585
Browse files Browse the repository at this point in the history
  • Loading branch information
PEZ committed Mar 8, 2022
1 parent e81595d commit 3104924
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/extension-test/unit/cursor-doc/token-cursor-test.ts
Expand Up @@ -386,7 +386,7 @@ describe('Token Cursor', () => {
cursor.forwardList();
expect(cursor.offsetStart).toBe(b.selectionLeft);
});
it('Does not move when unbalanced from extra opens', () => {
it('Does not move when at start of unbalanced list', () => {
// https://github.com/BetterThanTomorrow/calva/issues/1573
// https://github.com/BetterThanTomorrow/calva/commit/d77359fcea16bc052ab829853d5711434330a375
const a = docFromTextNotation('([|');
Expand All @@ -396,6 +396,14 @@ describe('Token Cursor', () => {
expect(result).toBe(false);
expect(cursor.offsetStart).toBe(b.selectionLeft);
});
it('Moves to stary of unbalanced list', () => {
const a = docFromTextNotation('(let [a| a');
const b = docFromTextNotation('(let [|a a');
const cursor: LispTokenCursor = a.getTokenCursor(a.selectionLeft);
const result = cursor.backwardList();
expect(result).toBe(true);
expect(cursor.offsetStart).toBe(b.selectionLeft);
});
it('Finds the list start when unbalanced from extra closes outside the current list', () => {
const a = docFromTextNotation('([]|))');
const b = docFromTextNotation('(|[]))');
Expand Down
15 changes: 15 additions & 0 deletions test-data/calva-252-hang.clj
@@ -0,0 +1,15 @@
;; https://github.com/BetterThanTomorrow/calva/issues/1585

;; Confirm that structural editing works here:

(defn foo [{:keys [bar]}] 'baz)

;; Here a repro that works for at least one user:
;; Place the cursor to the right of the closing square bracket and press delete
;; until the text is `(let [a] a)`. Then highlight the select the closing square
;; bracket and press delete. Structural editing and rainbow parens is now broken.

(let [a "123"] a)

(let [a] a)

0 comments on commit 3104924

Please sign in to comment.