Skip to content

Commit

Permalink
Fix find current form when squeezed between ignore and list
Browse files Browse the repository at this point in the history
  • Loading branch information
PEZ committed Apr 22, 2024
1 parent 594d7f0 commit 271af11
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/cursor-doc/token-cursor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -653,6 +653,7 @@ export class LispTokenCursor extends TokenCursor {
cursor.getToken().type !== 'reader' &&
!cursor.tokenBeginsMetadata() &&
cursor.getPrevToken().type !== 'reader' &&
cursor.getPrevToken().type !== 'ignore' &&
!cursor.prevTokenBeginsMetadata()
) {
if (cursor.backwardSexp() && !cursor.tokenBeginsMetadata()) {
Expand Down
12 changes: 12 additions & 0 deletions src/extension-test/unit/cursor-doc/token-cursor-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -747,6 +747,18 @@ describe('Token Cursor', () => {
const cursor: LispTokenCursor = a.getTokenCursor(a.selections[0].anchor);
expect(cursor.rangeForCurrentForm(a.selections[0].anchor)).toBeUndefined();
});
it('Selects atomic form to the right, when squeezed by an ignore marker', () => {
const a = docFromTextNotation('#_|a');
const b = docFromTextNotation('#_|a|');
const cursor: LispTokenCursor = a.getTokenCursor(a.selections[0].anchor);
expect(cursor.rangeForCurrentForm(a.selections[0].anchor)).toEqual(textAndSelection(b)[1]);
});
it('Selects list form to the right, when squeezed by an ignore marker', () => {
const a = docFromTextNotation('#_|(a)');
const b = docFromTextNotation('#_|(a)|');
const cursor: LispTokenCursor = a.getTokenCursor(a.selections[0].anchor);
expect(cursor.rangeForCurrentForm(a.selections[0].anchor)).toEqual(textAndSelection(b)[1]);
});
});

describe('Top Level Form', () => {
Expand Down

0 comments on commit 271af11

Please sign in to comment.