File tree Expand file tree Collapse file tree 1 file changed +7
-7
lines changed Expand file tree Collapse file tree 1 file changed +7
-7
lines changed Original file line number Diff line number Diff line change @@ -164,24 +164,24 @@ function activateCodeSnippet(
164164 execute : ( ) => {
165165 const highlightedCode = getSelectedText ( ) ;
166166 if ( highlightedCode === '' ) {
167- //if user just right-clicks the whole cell to save
167+ //if user just right-clicks cell(s) to save
168168 const curr = document . getElementsByClassName ( 'jp-Cell jp-mod-selected' ) ;
169169 const resultArray = [ ] ;
170170 for ( let i = 1 ; i < curr . length ; i ++ ) {
171+ //loop through each cell
171172 const text = curr [ i ] as HTMLElement ;
172173 const textContent = text . innerText ;
173174 const arrayInput = textContent . split ( '\n' ) ;
174175 const indexedInput = arrayInput . slice ( 1 ) ;
175176 for ( let i = 0 ; i < indexedInput . length ; i ++ ) {
176- for ( let j = 0 ; j < indexedInput [ i ] . length ; j ++ ) {
177- if ( indexedInput [ i ] . charCodeAt ( j ) === 8203 ) {
178- indexedInput [ i ] = '' ;
179- }
177+ // looping through each line in cell
178+ if ( indexedInput [ i ] . charCodeAt ( 0 ) === 8203 ) {
179+ //check if first char in line is invalid
180+ indexedInput [ i ] = '' ; //replace invalid line with empty string
180181 }
181- resultArray . push ( indexedInput [ i ] ) ;
182+ resultArray . push ( indexedInput [ i ] ) ; //push cell code lines into result
182183 }
183184 }
184- console . log ( resultArray ) ;
185185 CodeSnippetInputDialog ( codeSnippetWidget , resultArray , - 1 ) ;
186186 } else {
187187 CodeSnippetInputDialog (
You can’t perform that action at this time.
0 commit comments