Skip to content

Commit 271af11

Browse files
committed
Fix find current form when squeezed between ignore and list
1 parent 594d7f0 commit 271af11

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

src/cursor-doc/token-cursor.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -653,6 +653,7 @@ export class LispTokenCursor extends TokenCursor {
653653
cursor.getToken().type !== 'reader' &&
654654
!cursor.tokenBeginsMetadata() &&
655655
cursor.getPrevToken().type !== 'reader' &&
656+
cursor.getPrevToken().type !== 'ignore' &&
656657
!cursor.prevTokenBeginsMetadata()
657658
) {
658659
if (cursor.backwardSexp() && !cursor.tokenBeginsMetadata()) {

src/extension-test/unit/cursor-doc/token-cursor-test.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -747,6 +747,18 @@ describe('Token Cursor', () => {
747747
const cursor: LispTokenCursor = a.getTokenCursor(a.selections[0].anchor);
748748
expect(cursor.rangeForCurrentForm(a.selections[0].anchor)).toBeUndefined();
749749
});
750+
it('Selects atomic form to the right, when squeezed by an ignore marker', () => {
751+
const a = docFromTextNotation('#_|a');
752+
const b = docFromTextNotation('#_|a|');
753+
const cursor: LispTokenCursor = a.getTokenCursor(a.selections[0].anchor);
754+
expect(cursor.rangeForCurrentForm(a.selections[0].anchor)).toEqual(textAndSelection(b)[1]);
755+
});
756+
it('Selects list form to the right, when squeezed by an ignore marker', () => {
757+
const a = docFromTextNotation('#_|(a)');
758+
const b = docFromTextNotation('#_|(a)|');
759+
const cursor: LispTokenCursor = a.getTokenCursor(a.selections[0].anchor);
760+
expect(cursor.rangeForCurrentForm(a.selections[0].anchor)).toEqual(textAndSelection(b)[1]);
761+
});
750762
});
751763

752764
describe('Top Level Form', () => {

0 commit comments

Comments
 (0)