@@ -73,6 +73,7 @@ function parseClojure(content: string): vscode.NotebookCellData[] {
73
73
while ( commentStartCursor . forwardSexp ( ) ) {
74
74
const range = commentStartCursor . rangeForDefun ( commentStartCursor . offsetStart ) ;
75
75
let leading = '' ;
76
+ const indent = commentStartCursor . doc . getRowCol ( range [ 0 ] ) [ 1 ] ; // will break with tabs?
76
77
77
78
leading = content . substring ( previouseEnd , range [ 0 ] ) ;
78
79
previouseEnd = range [ 1 ] ;
@@ -83,6 +84,7 @@ function parseClojure(content: string): vscode.NotebookCellData[] {
83
84
languageId : 'clojure' ,
84
85
metadata : {
85
86
leading : leading ,
87
+ indent,
86
88
range,
87
89
richComment : true ,
88
90
trailing : '' ,
@@ -100,6 +102,7 @@ function parseClojure(content: string): vscode.NotebookCellData[] {
100
102
kind : vscode . NotebookCellKind . Code ,
101
103
languageId : 'clojure' ,
102
104
metadata : {
105
+ indent : 0 ,
103
106
leading : '' ,
104
107
trailing : '' ,
105
108
} ,
@@ -110,13 +113,15 @@ function parseClojure(content: string): vscode.NotebookCellData[] {
110
113
}
111
114
112
115
function writeCellsToClojure ( cells : vscode . NotebookCellData [ ] ) {
113
- return cells . reduce ( ( acc , x ) => {
116
+ return cells . reduce ( ( acc , x , index ) => {
114
117
if ( x . kind === vscode . NotebookCellKind . Code ) {
115
118
let result = '' ;
116
119
117
120
// created inside the notebook
118
121
if ( undefined === x . metadata . leading ) {
119
- result = '\n\n' + x . value ;
122
+ const indent = index > 0 ? _ . repeat ( ' ' , cells [ index - 1 ] . metadata . indent ) : '' ;
123
+
124
+ result = '\n\n' + indent + x . value ;
120
125
} else {
121
126
result = x . metadata . leading + x . value + x . metadata . trailing ;
122
127
}
0 commit comments