1
- import { isEqual , isNumber , last , pick , property , clone , isBoolean } from 'lodash' ;
1
+ import { isEqual , last , pick , property , clone , isBoolean , orderBy } from 'lodash' ;
2
2
import { validPair } from './clojure-lexer' ;
3
- import { EditableDocument , ModelEdit , ModelEditSelection , ModelEditResult } from './model' ;
3
+ import {
4
+ EditableDocument ,
5
+ ModelEdit ,
6
+ ModelEditSelection ,
7
+ ModelEditResult ,
8
+ ModelEditFunctionArgs ,
9
+ } from './model' ;
4
10
import { LispTokenCursor } from './token-cursor' ;
5
11
import { replaceAt } from '../util/array' ;
6
- import { ShowDocumentRequest } from 'vscode-languageclient' ;
7
12
8
13
// NB: doc.model.edit returns a Thenable, so that the vscode Editor can compose commands.
9
14
// But don't put such chains in this module because that won't work in the repl-console.
@@ -595,8 +600,8 @@ export function wrapSexpr(
595
600
new ModelEdit ( 'insertString' , [
596
601
range [ 0 ] ,
597
602
open ,
598
- [ end , end ] ,
599
- [ start + open . length , start + open . length ] ,
603
+ // [end, end],
604
+ // [start + open.length, start + open.length],
600
605
] ) ,
601
606
] ,
602
607
{
@@ -703,8 +708,8 @@ export function joinSexp(doc: EditableDocument): Thenable<ModelEditResult> {
703
708
prevEnd - 1 ,
704
709
nextStart + 1 ,
705
710
prevToken . type === 'close' ? ' ' : '' ,
706
- [ start , start ] ,
707
- [ prevEnd , prevEnd ] ,
711
+ // [start, start],
712
+ // [prevEnd, prevEnd],
708
713
] )
709
714
) ;
710
715
selections [ index ] = new ModelEditSelection ( prevEnd ) ;
@@ -810,7 +815,7 @@ export function _forwardSlurpSexpSingle(
810
815
const wsEndOffset = wsOutSideCursor . offsetStart ;
811
816
const newCloseOffset = cursor . offsetStart ;
812
817
const replacedText = doc . model . getText ( wsStartOffset , wsEndOffset ) ;
813
- const changeArgs =
818
+ const changeArgs : ModelEditFunctionArgs < 'changeRange' > =
814
819
replacedText . indexOf ( '\n' ) >= 0
815
820
? [ currentCloseOffset , currentCloseOffset + close . length , '' ]
816
821
: [ wsStartOffset , wsEndOffset , ' ' ] ;
@@ -1454,13 +1459,7 @@ export function transpose(
1454
1459
}
1455
1460
edits . push (
1456
1461
new ModelEdit ( 'changeRange' , [ rightStart , rightEnd , leftText ] ) ,
1457
- new ModelEdit ( 'changeRange' , [
1458
- leftStart ,
1459
- leftEnd ,
1460
- rightText ,
1461
- [ left , left ] ,
1462
- [ newCursorPos , newCursorPos ] ,
1463
- ] )
1462
+ new ModelEdit ( 'changeRange' , [ leftStart , leftEnd , rightText ] )
1464
1463
) ;
1465
1464
selections [ index ] = new ModelEditSelection ( newCursorPos ) ;
1466
1465
}
@@ -1681,10 +1680,7 @@ export function dragSexprBackwardUp(
1681
1680
wsInfo . rightWsRange [ 1 ] - currentRange [ 0 ] ,
1682
1681
] ) ;
1683
1682
}
1684
- edits . push (
1685
- deleteEdit ,
1686
- new ModelEdit ( 'insertString' , [ listStart , dragText , [ p , p ] , [ newCursorPos , newCursorPos ] ] )
1687
- ) ;
1683
+ edits . push ( deleteEdit , new ModelEdit ( 'insertString' , [ listStart , dragText ] ) ) ;
1688
1684
selections [ index ] = new ModelEditSelection ( newCursorPos ) ;
1689
1685
}
1690
1686
} ) ;
@@ -1722,12 +1718,7 @@ export function dragSexprForwardDown(
1722
1718
const insertText =
1723
1719
doc . model . getText ( ...currentRange ) + ( wsInfo . rightWsHasNewline ? '\n' : ' ' ) ;
1724
1720
edits . push (
1725
- new ModelEdit ( 'insertString' , [
1726
- insertStart ,
1727
- insertText ,
1728
- [ p , p ] ,
1729
- [ newCursorPos , newCursorPos ] ,
1730
- ] ) ,
1721
+ new ModelEdit ( 'insertString' , [ insertStart , insertText ] ) ,
1731
1722
new ModelEdit ( 'deleteRange' , [ currentRange [ 0 ] , deleteLength ] )
1732
1723
) ;
1733
1724
selections [ index ] = new ModelEditSelection ( newCursorPos ) ;
@@ -1770,7 +1761,7 @@ export function dragSexprForwardUp(
1770
1761
}
1771
1762
const newCursorPos = listEnd + newPosOffset + 1 - deleteLength ;
1772
1763
edits . push (
1773
- new ModelEdit ( 'insertString' , [ listEnd , dragText , [ p , p ] , [ newCursorPos , newCursorPos ] ] ) ,
1764
+ new ModelEdit ( 'insertString' , [ listEnd , dragText ] ) ,
1774
1765
new ModelEdit ( 'deleteRange' , [ deleteStart , deleteLength ] )
1775
1766
) ;
1776
1767
selections [ index ] = new ModelEditSelection ( newCursorPos ) ;
@@ -1813,12 +1804,7 @@ export function dragSexprBackwardDown(
1813
1804
insertText = ( siblingWsInfo . leftWsHasNewline ? '\n' : ' ' ) + insertText ;
1814
1805
edits . push (
1815
1806
new ModelEdit ( 'deleteRange' , [ wsInfo . leftWsRange [ 0 ] , deleteLength ] ) ,
1816
- new ModelEdit ( 'insertString' , [
1817
- insertStart ,
1818
- insertText ,
1819
- [ p , p ] ,
1820
- [ newCursorPos , newCursorPos ] ,
1821
- ] )
1807
+ new ModelEdit ( 'insertString' , [ insertStart , insertText ] )
1822
1808
) ;
1823
1809
selections [ index ] = new ModelEditSelection ( newCursorPos ) ;
1824
1810
break ;
@@ -1872,21 +1858,11 @@ export function addRichComment(
1872
1858
checkIfRichCommentExistsCursor . forwardWhitespace ( false ) ;
1873
1859
// insert nothing, just place cursor
1874
1860
const newCursorPos = checkIfRichCommentExistsCursor . offsetStart ;
1875
- void doc . model . edit (
1876
- [
1877
- new ModelEdit ( 'insertString' , [
1878
- newCursorPos ,
1879
- '' ,
1880
- [ newCursorPos , newCursorPos ] ,
1881
- [ newCursorPos , newCursorPos ] ,
1882
- ] ) ,
1883
- ] ,
1884
- {
1885
- selections : [ new ModelEditSelection ( newCursorPos ) ] ,
1886
- skipFormat : true ,
1887
- undoStopBefore : false ,
1888
- }
1889
- ) ;
1861
+ void doc . model . edit ( [ new ModelEdit ( 'insertString' , [ newCursorPos , '' ] ) ] , {
1862
+ selections : [ new ModelEditSelection ( newCursorPos ) ] ,
1863
+ skipFormat : true ,
1864
+ undoStopBefore : false ,
1865
+ } ) ;
1890
1866
return ;
1891
1867
}
1892
1868
}
@@ -1900,19 +1876,9 @@ export function addRichComment(
1900
1876
const append = '\n' . repeat ( numAppendNls ) ;
1901
1877
const insertText = `${ prepend } ${ richComment } ${ append } ` ;
1902
1878
const newCursorPos = insertStart + 11 + numPrependNls * doc . model . lineEndingLength ;
1903
- void doc . model . edit (
1904
- [
1905
- new ModelEdit ( 'insertString' , [
1906
- insertStart ,
1907
- insertText ,
1908
- [ insertStart , insertStart ] ,
1909
- [ newCursorPos , newCursorPos ] ,
1910
- ] ) ,
1911
- ] ,
1912
- {
1913
- selections : [ new ModelEditSelection ( newCursorPos ) ] ,
1914
- skipFormat : false ,
1915
- undoStopBefore : true ,
1916
- }
1917
- ) ;
1879
+ void doc . model . edit ( [ new ModelEdit ( 'insertString' , [ insertStart , insertText ] ) ] , {
1880
+ selections : [ new ModelEditSelection ( newCursorPos ) ] ,
1881
+ skipFormat : false ,
1882
+ undoStopBefore : true ,
1883
+ } ) ;
1918
1884
}
0 commit comments