@@ -8,6 +8,7 @@ import { VSBuffer } from '../../../../../base/common/buffer.js';
8
8
import { DisposableStore } from '../../../../../base/common/lifecycle.js' ;
9
9
import { Mimes } from '../../../../../base/common/mime.js' ;
10
10
import { ensureNoDisposablesAreLeakedInTestSuite } from '../../../../../base/test/common/utils.js' ;
11
+ import { Position } from '../../../../../editor/common/core/position.js' ;
11
12
import { ILanguageService } from '../../../../../editor/common/languages/language.js' ;
12
13
import { TestInstantiationService } from '../../../../../platform/instantiation/test/common/instantiationServiceMock.js' ;
13
14
import { IUndoRedoService } from '../../../../../platform/undoRedo/common/undoRedo.js' ;
@@ -1454,31 +1455,31 @@ suite('NotebookTextModel', () => {
1454
1455
const notebookModel = viewModel . notebookDocument ;
1455
1456
1456
1457
// Test case 1: Find 'var' starting from the first cell
1457
- let findMatch = notebookModel . findNextMatch ( 'var' , { cellIndex : 0 , position : { lineNumber : 1 , column : 1 } } , false , false , null ) ;
1458
+ let findMatch = notebookModel . findNextMatch ( 'var' , { cellIndex : 0 , position : new Position ( 1 , 1 ) } , false , false , null ) ;
1458
1459
assert . ok ( findMatch ) ;
1459
1460
assert . strictEqual ( findMatch ! . match . range . startLineNumber , 1 ) ;
1460
1461
assert . strictEqual ( findMatch ! . match . range . startColumn , 1 ) ;
1461
1462
1462
1463
// Test case 2: Find 'b' starting from the second cell
1463
- findMatch = notebookModel . findNextMatch ( 'b' , { cellIndex : 1 , position : { lineNumber : 1 , column : 1 } } , false , false , null ) ;
1464
+ findMatch = notebookModel . findNextMatch ( 'b' , { cellIndex : 1 , position : new Position ( 1 , 1 ) } , false , false , null ) ;
1464
1465
assert . ok ( findMatch ) ;
1465
1466
assert . strictEqual ( findMatch ! . match . range . startLineNumber , 1 ) ;
1466
1467
assert . strictEqual ( findMatch ! . match . range . startColumn , 5 ) ;
1467
1468
1468
1469
// Test case 3: Find 'c' starting from the third cell
1469
- findMatch = notebookModel . findNextMatch ( 'c' , { cellIndex : 2 , position : { lineNumber : 1 , column : 1 } } , false , false , null ) ;
1470
+ findMatch = notebookModel . findNextMatch ( 'c' , { cellIndex : 2 , position : new Position ( 1 , 1 ) } , false , false , null ) ;
1470
1471
assert . ok ( findMatch ) ;
1471
1472
assert . strictEqual ( findMatch ! . match . range . startLineNumber , 1 ) ;
1472
1473
assert . strictEqual ( findMatch ! . match . range . startColumn , 5 ) ;
1473
1474
1474
1475
// Test case 4: Find 'd' starting from the fourth cell
1475
- findMatch = notebookModel . findNextMatch ( 'd' , { cellIndex : 3 , position : { lineNumber : 1 , column : 1 } } , false , false , null ) ;
1476
+ findMatch = notebookModel . findNextMatch ( 'd' , { cellIndex : 3 , position : new Position ( 1 , 1 ) } , false , false , null ) ;
1476
1477
assert . ok ( findMatch ) ;
1477
1478
assert . strictEqual ( findMatch ! . match . range . startLineNumber , 1 ) ;
1478
1479
assert . strictEqual ( findMatch ! . match . range . startColumn , 5 ) ;
1479
1480
1480
1481
// Test case 5: No match found
1481
- findMatch = notebookModel . findNextMatch ( 'e' , { cellIndex : 0 , position : { lineNumber : 1 , column : 1 } } , false , false , null ) ;
1482
+ findMatch = notebookModel . findNextMatch ( 'e' , { cellIndex : 0 , position : new Position ( 1 , 1 ) } , false , false , null ) ;
1482
1483
assert . strictEqual ( findMatch , null ) ;
1483
1484
}
1484
1485
) ;
@@ -1496,52 +1497,52 @@ suite('NotebookTextModel', () => {
1496
1497
const notebookModel = viewModel . notebookDocument ;
1497
1498
1498
1499
// Test case 1: Find 'var' starting from the first cell
1499
- let findMatch = notebookModel . findNextMatch ( 'var' , { cellIndex : 0 , position : { lineNumber : 1 , column : 1 } } , false , false , null ) ;
1500
+ let findMatch = notebookModel . findNextMatch ( 'var' , { cellIndex : 0 , position : new Position ( 1 , 1 ) } , false , false , null ) ;
1500
1501
assert . ok ( findMatch ) ;
1501
1502
assert . strictEqual ( findMatch ! . match . range . startLineNumber , 1 ) ;
1502
1503
assert . strictEqual ( findMatch ! . match . range . startColumn , 1 ) ;
1503
1504
1504
1505
// Test case 2: Find 'b' starting from the second cell
1505
- findMatch = notebookModel . findNextMatch ( 'b' , { cellIndex : 1 , position : { lineNumber : 1 , column : 1 } } , false , false , null ) ;
1506
+ findMatch = notebookModel . findNextMatch ( 'b' , { cellIndex : 1 , position : new Position ( 1 , 1 ) } , false , false , null ) ;
1506
1507
assert . ok ( findMatch ) ;
1507
1508
assert . strictEqual ( findMatch ! . match . range . startLineNumber , 1 ) ;
1508
1509
assert . strictEqual ( findMatch ! . match . range . startColumn , 5 ) ;
1509
1510
1510
1511
// Test case 3: Find 'c' starting from the third cell
1511
- findMatch = notebookModel . findNextMatch ( 'c' , { cellIndex : 2 , position : { lineNumber : 1 , column : 1 } } , false , false , null ) ;
1512
+ findMatch = notebookModel . findNextMatch ( 'c' , { cellIndex : 2 , position : new Position ( 1 , 1 ) } , false , false , null ) ;
1512
1513
assert . ok ( findMatch ) ;
1513
1514
assert . strictEqual ( findMatch ! . match . range . startLineNumber , 1 ) ;
1514
1515
assert . strictEqual ( findMatch ! . match . range . startColumn , 5 ) ;
1515
1516
1516
1517
// Test case 4: Find 'd' starting from the fourth cell
1517
- findMatch = notebookModel . findNextMatch ( 'd' , { cellIndex : 3 , position : { lineNumber : 1 , column : 1 } } , false , false , null ) ;
1518
+ findMatch = notebookModel . findNextMatch ( 'd' , { cellIndex : 3 , position : new Position ( 1 , 1 ) } , false , false , null ) ;
1518
1519
assert . ok ( findMatch ) ;
1519
1520
assert . strictEqual ( findMatch ! . match . range . startLineNumber , 1 ) ;
1520
1521
assert . strictEqual ( findMatch ! . match . range . startColumn , 5 ) ;
1521
1522
1522
1523
// Test case 5: No match found
1523
- findMatch = notebookModel . findNextMatch ( 'e' , { cellIndex : 0 , position : { lineNumber : 1 , column : 1 } } , false , false , null ) ;
1524
+ findMatch = notebookModel . findNextMatch ( 'e' , { cellIndex : 0 , position : new Position ( 1 , 1 ) } , false , false , null ) ;
1524
1525
assert . strictEqual ( findMatch , null ) ;
1525
1526
1526
1527
// Test case 6: Same keywords in the same cell
1527
- findMatch = notebookModel . findNextMatch ( 'var' , { cellIndex : 0 , position : { lineNumber : 1 , column : 1 } } , false , false , null ) ;
1528
+ findMatch = notebookModel . findNextMatch ( 'var' , { cellIndex : 0 , position : new Position ( 1 , 1 ) } , false , false , null ) ;
1528
1529
assert . ok ( findMatch ) ;
1529
1530
assert . strictEqual ( findMatch ! . match . range . startLineNumber , 1 ) ;
1530
1531
assert . strictEqual ( findMatch ! . match . range . startColumn , 1 ) ;
1531
1532
1532
- findMatch = notebookModel . findNextMatch ( 'var' , { cellIndex : 0 , position : { lineNumber : 1 , column : 5 } } , false , false , null ) ;
1533
+ findMatch = notebookModel . findNextMatch ( 'var' , { cellIndex : 0 , position : new Position ( 1 , 5 ) } , false , false , null ) ;
1533
1534
assert . ok ( findMatch ) ;
1534
1535
assert . strictEqual ( findMatch ! . match . range . startLineNumber , 1 ) ;
1535
1536
assert . strictEqual ( findMatch ! . match . range . startColumn , 12 ) ;
1536
1537
1537
1538
// Test case 7: Search from the middle of a cell with keyword before and after
1538
- findMatch = notebookModel . findNextMatch ( 'a' , { cellIndex : 0 , position : { lineNumber : 1 , column : 10 } } , false , false , null ) ;
1539
+ findMatch = notebookModel . findNextMatch ( 'a' , { cellIndex : 0 , position : new Position ( 1 , 10 ) } , false , false , null ) ;
1539
1540
assert . ok ( findMatch ) ;
1540
1541
assert . strictEqual ( findMatch ! . match . range . startLineNumber , 1 ) ;
1541
1542
assert . strictEqual ( findMatch ! . match . range . startColumn , 13 ) ;
1542
1543
1543
1544
// Test case 8: Search from a cell and next match is in another cell below
1544
- findMatch = notebookModel . findNextMatch ( 'var' , { cellIndex : 0 , position : { lineNumber : 1 , column : 20 } } , false , false , null ) ;
1545
+ findMatch = notebookModel . findNextMatch ( 'var' , { cellIndex : 0 , position : new Position ( 1 , 20 ) } , false , false , null ) ;
1545
1546
assert . ok ( findMatch ) ;
1546
1547
assert . strictEqual ( findMatch ! . match . range . startLineNumber , 1 ) ;
1547
1548
assert . strictEqual ( findMatch ! . match . range . startColumn , 1 ) ;
0 commit comments