Skip to content

Commit e8d68ee

Browse files
committed
Merge branch dev into published
2 parents 5e124de + f54e50a commit e8d68ee

File tree

9 files changed

+58
-16
lines changed

9 files changed

+58
-16
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@ Changes to Calva.
44

55
## [Unreleased]
66

7+
## [2.0.322] - 2022-12-14
8+
9+
- Fix: [Clojure notebooks don't seem to work on MS-Windows](https://github.com/BetterThanTomorrow/calva/issues/1994)
10+
- Fix: [Calva development: npm run prettier-format fails on MS-Windows](https://github.com/BetterThanTomorrow/calva/issues/1996)
11+
- Bump bundled deps.clj to v1.11.1.1208
12+
713
## [2.0.321] - 2022-12-05
814

915
- Fix: [Supplying a custom printFn to the pretty printer does not work](https://github.com/BetterThanTomorrow/calva/issues/1979)

deps-clj-version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
v1.11.1.1200
1+
v1.11.1.1208

deps.clj.jar

190 Bytes
Binary file not shown.

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"displayName": "Calva: Clojure & ClojureScript Interactive Programming",
44
"description": "Integrated REPL, formatter, Paredit, and more. Powered by cider-nrepl and clojure-lsp.",
55
"icon": "assets/calva.png",
6-
"version": "2.0.321",
6+
"version": "2.0.322",
77
"publisher": "betterthantomorrow",
88
"author": {
99
"name": "Better Than Tomorrow",
@@ -2881,10 +2881,10 @@
28812881
"integration-test": "node ./out/extension-test/integration/runTests.js",
28822882
"unit-test": "npx mocha --require ts-node/register 'src/extension-test/unit/**/*-test.ts'",
28832883
"unit-test-watch": "npx mocha --watch --require ts-node/register --watch-extensions ts --watch-files src 'src/extension-test/unit/**/*-test.ts'",
2884-
"prettier-format": "npx prettier --write './**/*.{ts,js,json}'",
2885-
"prettier-check": "npx prettier --check './**/*.{ts,js,json}'",
2886-
"prettier-check-watch": "onchange './**/*.{ts,js,json}' -- prettier --check {{changed}}",
2887-
"prettier-format-watch": "onchange './**/*.{ts,js,json}' -- prettier --write {{changed}}",
2884+
"prettier-format": "npx prettier --write \"./**/*.{ts,js,json}\"",
2885+
"prettier-check": "npx prettier --check \"./**/*.{ts,js,json}\"",
2886+
"prettier-check-watch": "onchange \"./**/*.{ts,js,json}\" -- prettier --check {{changed}}",
2887+
"prettier-format-watch": "onchange \"./**/*.{ts,js,json}\" -- prettier --write {{changed}}",
28882888
"preprettier-format-watch": "npm run prettier-format",
28892889
"eslint": "npx eslint . --ext .js,.jsx,.ts,.tsx",
28902890
"eslint-watch": "npx esw . --ext .js,.jsx,.ts,.tsx --watch"

src/cursor-doc/model.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,14 @@ export function initScanner(maxLength: number) {
99
scanner = new Scanner(maxLength);
1010
}
1111

12+
/**
13+
* @param text The text to look in for the end of line seq.
14+
* @returns The first end of line sequence found in TEXT, if any.
15+
*/
16+
export function getFirstEol(text: string) {
17+
return text.match(/\r\n|\n/g)?.[0];
18+
}
19+
1220
export class TextLine {
1321
tokens: Token[] = [];
1422
text: string;
@@ -527,14 +535,17 @@ export class LineInputModel implements EditableModel {
527535

528536
export class StringDocument implements EditableDocument {
529537
constructor(contents?: string) {
538+
const eol = contents ? getFirstEol(contents) : null;
539+
540+
this.model = new LineInputModel(eol ? eol.length : 1, this);
530541
if (contents) {
531542
this.insertString(contents);
532543
}
533544
}
534545

535546
selection: ModelEditSelection;
536547

537-
model: LineInputModel = new LineInputModel(1, this);
548+
model: LineInputModel;
538549

539550
selectionStack: ModelEditSelection[] = [];
540551

src/cursor-doc/token-cursor.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { LineInputModel } from './model';
1+
import { getFirstEol, LineInputModel } from './model';
22
import { Token, validPair } from './clojure-lexer';
33

44
function tokenIsWhiteSpace(token: Token) {
@@ -943,7 +943,8 @@ export class LispTokenCursor extends TokenCursor {
943943
* Creates a `LispTokenCursor` for walking and manipulating the string `s`.
944944
*/
945945
export function createStringCursor(s: string): LispTokenCursor {
946-
const model = new LineInputModel();
946+
const eol = getFirstEol(s);
947+
const model = new LineInputModel(eol ? eol.length : 1);
947948
model.insertString(0, s);
948949
return model.getTokenCursor(0);
949950
}

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

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -177,8 +177,7 @@ describe('paredit', () => {
177177
const b = docFromTextNotation('(a| b (c\r\n d)| e)');
178178
const [start, end] = textAndSelection(b)[1];
179179
const actual = paredit.forwardHybridSexpRange(a);
180-
// off by 1 because \r\n is treated as 1 char?
181-
expect(actual).toEqual([start, end - 1]);
180+
expect(actual).toEqual([start, end]);
182181
});
183182

184183
it('Maintains balanced delimiters 2', () => {
@@ -194,8 +193,7 @@ describe('paredit', () => {
194193
const b = docFromTextNotation('(aa| (c (e\r\nf))|g)');
195194
const [start, end] = textAndSelection(b)[1];
196195
const actual = paredit.forwardHybridSexpRange(a);
197-
// off by 1 because \r\n is treated as 1 char?
198-
expect(actual).toEqual([start, end - 1]);
196+
expect(actual).toEqual([start, end]);
199197
});
200198

201199
it('Maintains balanced delimiters 3', () => {

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

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import * as expect from 'expect';
2-
import { LispTokenCursor } from '../../../cursor-doc/token-cursor';
2+
import { createStringCursor, LispTokenCursor } from '../../../cursor-doc/token-cursor';
33
import { docFromTextNotation, textAndSelection } from '../common/text-notation';
44

55
describe('Token Cursor', () => {
@@ -28,6 +28,20 @@ describe('Token Cursor', () => {
2828
cursor.forwardSexp();
2929
expect(cursor.offsetStart).toBe(b.selection.anchor);
3030
});
31+
it('forwardSexp with newline', () => {
32+
const a = docFromTextNotation('|(a\n(b))');
33+
const b = docFromTextNotation('(a\n(b))|');
34+
const cursor: LispTokenCursor = a.getTokenCursor(a.selection.anchor);
35+
cursor.forwardSexp();
36+
expect(cursor.offsetStart).toBe(b.selection.anchor);
37+
});
38+
it('forwardSexp with newline (MS-Windows)', () => {
39+
const a = docFromTextNotation('|(a\r\n(b))');
40+
const b = docFromTextNotation('(a\r\n(b))|');
41+
const cursor: LispTokenCursor = a.getTokenCursor(a.selection.anchor);
42+
cursor.forwardSexp();
43+
expect(cursor.offsetStart).toBe(b.selection.anchor);
44+
});
3145
it('moves from beginning to end of nested list ', () => {
3246
const a = docFromTextNotation('|(a(b(c•#f•(#b •[:f])•#z•1)))');
3347
const b = docFromTextNotation('(a(b(c•#f•(#b •[:f])•#z•1)))|');
@@ -876,6 +890,18 @@ describe('Token Cursor', () => {
876890
expect(cursor.getFunctionName()).toBeUndefined();
877891
});
878892
});
893+
describe('createStringCursor', () => {
894+
it('Ranges account for newline', () => {
895+
const cursor = createStringCursor('(a\n(b))');
896+
const topLevelRanges = cursor.rangesForTopLevelForms().flat();
897+
expect(topLevelRanges).toEqual([0, 7]);
898+
});
899+
it('Ranges account for newline (MS-Windows)', () => {
900+
const cursor = createStringCursor('(a\r\n(b))');
901+
const topLevelRanges = cursor.rangesForTopLevelForms().flat();
902+
expect(topLevelRanges).toEqual([0, 8]);
903+
});
904+
});
879905
});
880906

881907
describe('Location State', () => {

0 commit comments

Comments
 (0)