@@ -12,12 +12,12 @@ const folderMD = require('./Controllers/convertToMdFolder');
1212 */
1313function activate ( context ) {
1414 console . log ( 'Extension is now active!' ) ;
15-
15+
1616 let disposable = vscode . commands . registerCommand ( "extension.showTextField" , function ( ) {
1717 let editor = vscode . window . activeTextEditor ;
1818 vscode . window . showInputBox ( {
19- prompt : "Enter your text"
20- } ) . then ( function ( inputText ) {
19+ prompt : "Enter your text"
20+ } ) . then ( function ( inputText ) {
2121 editor . edit ( editBuilder => {
2222 if ( inputText != undefined ) {
2323
@@ -29,22 +29,22 @@ function activate(context) {
2929
3030
3131 if ( editor . selection . start . line === editor . selection . end . line ) {
32- inputText = " " + checkLanguage ( ) + " @/w" + `${ id } ` + " " + inputText
32+ inputText = " " + checkLanguage ( ) + " @/w" + `${ id } ` + " " + inputText
3333 } else {
3434 inputText = checkLanguage ( ) + " @<r" + `${ id } ` + " " + inputText
3535 }
3636
3737
3838 closingText = checkLanguage ( ) + " @r>" + `${ id } `
39-
39+
4040 let newText ;
41-
41+
4242 if ( editor . selection . start . line === editor . selection . end . line ) {
43- newText = `${ editor . document . getText ( editor . selection ) } ` + `${ inputText } `
43+ newText = `${ editor . document . getText ( editor . selection ) } ` + `${ inputText } `
4444 } else {
4545 newText = `${ inputText } ` + '\n' + `${ editor . document . getText ( editor . selection ) } ` + '\n' + `${ closingText } `
4646 }
47-
47+
4848
4949 const selections = editor . selections ; // to handle mutliple selection
5050 for ( const selection of selections ) {
@@ -54,7 +54,7 @@ function activate(context) {
5454 } ) ;
5555 } ) ;
5656 } ) ;
57-
57+
5858 let callParserNConverter = vscode . commands . registerCommand ( "extension.callParserNConverter" , async function ( ) {
5959 console . log ( "calling parser n converter" )
6060
@@ -67,7 +67,7 @@ function activate(context) {
6767
6868 let files = await vscode . workspace . findFiles ( '**/*.*' , '**/node_modules/**' ) ;
6969 files = files . sort ( )
70- fs . writeFileSync ( `${ writePath } /markdownfile.md` , "" )
70+ fs . writeFileSync ( `${ writePath } /markdownfile.md` , "" )
7171
7272 // folder info if available
7373 async function processFolder ( ) {
@@ -80,24 +80,24 @@ function activate(context) {
8080 console . log ( e )
8181 }
8282 }
83-
83+
8484 processFolder ( )
8585
8686 async function processFiles ( ) {
8787 for ( let i = 0 ; i < files . length ; i ++ ) {
88- let file = files [ i ] . fsPath ;
89- try {
90- const arrayOfItemCode = await fileParser . fileParser ( file , writePath , getFileName ( file ) ) ;
91- if ( arrayOfItemCode != undefined ) {
92- await fileToMD . convertToMDFile ( arrayOfItemCode , writePath , getFileName ( file ) ) ;
88+ let file = files [ i ] . fsPath ;
89+ try {
90+ const arrayOfItemCode = await fileParser . fileParser ( file , writePath , getFileName ( file ) ) ;
91+ if ( arrayOfItemCode != undefined ) {
92+ await fileToMD . convertToMDFile ( arrayOfItemCode , writePath , getFileName ( file ) ) ;
93+ }
94+ } catch ( e ) {
95+ console . log ( e ) ;
9396 }
94- } catch ( e ) {
95- console . log ( e ) ;
96- }
9797 }
98- }
99-
100- processFiles ( ) ;
98+ }
99+
100+ processFiles ( ) ;
101101 } )
102102
103103 let gptAPI = vscode . commands . registerCommand ( "extension.gptAPI" , async function ( ) {
@@ -107,80 +107,80 @@ function activate(context) {
107107
108108 await vscode . window . withProgress ( {
109109 location : vscode . ProgressLocation . Notification ,
110- title : "Smart Comments " ,
110+ title : "Smart Comments" ,
111111 cancellable : false
112- } , async ( progress ) => {
112+ } , async ( progress ) => {
113113 // simulate a long-running task
114114 progress . report ( { message : "Running GPT..." } ) ;
115115 await new Promise ( resolve => setTimeout ( resolve , 100 ) ) ;
116-
116+
117117 if ( editor . document . getText ( editor . selection ) . trim ( ) == "" ) {
118118 progress . report ( { increment : 100 , message : "Error. Please select something." } ) ;
119119 await new Promise ( resolve => setTimeout ( resolve , 100 ) ) ;
120120 return
121- }
121+ }
122122
123123 let codeExplication = await gptController . runCompletion ( editor . document . getText ( editor . selection ) )
124124
125125 codeExplication = codeExplication . trim ( )
126-
126+
127127 // update the progress indicator
128128 progress . report ( { increment : 50 , message : "Processing results..." } ) ;
129129 await new Promise ( resolve => setTimeout ( resolve , 100 ) ) ;
130-
130+
131131 editor . edit ( editBuilder => {
132-
132+
133133 let id = Math . floor ( Math . random ( ) * ( 100 - 0 + 1 ) ) + 0
134134 while ( id in everyIDGenerated ) {
135135 id = Math . floor ( Math . random ( ) * ( 100 - 0 + 1 ) ) + 0
136136 }
137137 everyIDGenerated . push ( id )
138-
139-
138+
139+
140140 if ( editor . selection . start . line === editor . selection . end . line ) {
141- codeExplication = " " + checkLanguage ( ) + " @/w" + `${ id } ` + " " + codeExplication
141+ codeExplication = " " + checkLanguage ( ) + " @/w" + `${ id } ` + " " + codeExplication
142142 } else {
143143 codeExplication = checkLanguage ( ) + " @<r" + `${ id } ` + " " + codeExplication
144144 }
145145
146146 closingText = checkLanguage ( ) + " @r>" + `${ id } `
147-
147+
148148 let newText ;
149149
150150 if ( editor . selection . start . line === editor . selection . end . line ) {
151- newText = `${ editor . document . getText ( editor . selection ) } ` + `${ codeExplication } `
151+ newText = `${ editor . document . getText ( editor . selection ) } ` + `${ codeExplication } `
152152 } else {
153153 newText = `${ codeExplication } ` + '\n' + `${ editor . document . getText ( editor . selection ) } ` + '\n' + `${ closingText } `
154154 }
155-
155+
156156 const selections = editor . selections ; // to handle mutliple selection
157157 for ( const selection of selections ) {
158158 editBuilder . replace ( selection , newText ) ;
159159 }
160-
160+
161161 } )
162-
162+
163163 // update the progress indicator
164164 progress . report ( { increment : 50 , message : "Done!" } ) ;
165165 await new Promise ( resolve => setTimeout ( resolve , 1000 ) ) ;
166- } )
166+ } )
167167 } )
168168
169169 let createProjectInfoFile = vscode . commands . registerCommand ( "extension.createProjectInfoFile" , async function ( ) {
170170 console . log ( "creating project info file" )
171171
172172 fs . writeFileSync ( `${ vscode . workspace . workspaceFolders [ 0 ] . uri . fsPath } /info.pii` , infoPiiText )
173173 } )
174-
174+
175175 // Register the command to the keyboard shortcut
176176 context . subscriptions . push ( disposable ) ;
177177 context . subscriptions . push ( callParserNConverter ) ;
178178 context . subscriptions . push ( gptAPI ) ;
179179 context . subscriptions . push ( createProjectInfoFile ) ;
180- }
180+ }
181181
182182
183- function deactivate ( ) { }
183+ function deactivate ( ) { }
184184
185185module . exports = {
186186 activate,
@@ -191,11 +191,11 @@ function checkLanguage() {
191191 // si preferable law zabatit built in mais ca marchait pas pr aucune raison
192192 // a revoir
193193
194- const editor = vscode . window . activeTextEditor ;
194+ const editor = vscode . window . activeTextEditor ;
195195 const document = editor . document ;
196196 const language = document . languageId
197197
198- switch ( language ) {
198+ switch ( language ) {
199199 case "python" :
200200 return "#"
201201 case "ruby" :
@@ -219,5 +219,5 @@ function checkLanguage() {
219219
220220let everyIDGenerated = [ ]
221221
222- let infoPiiText =
223- "@title=\"title\"\n\n@version=\"v 1.1.1\"\n@date=\"12/12/12\"\n\n@authors=\"x, y, ghada\"\n@mail=\"x@mail.com, y@mail.com, ghada@mail.com\"\n\n@description=\"this is a description\"\n\n@requirements=\"ios16, windows11\"\n\n@paragraph=\"this is a paragraph\""
222+ let infoPiiText =
223+ "@title=\"title\"\n\n@version=\"v 1.1.1\"\n@date=\"12/12/12\"\n\n@authors=\"x, y, ghada\"\n@mail=\"x@mail.com, y@mail.com, ghada@mail.com\"\n\n@description=\"this is a description\"\n\n@requirements=\"ios16, windows11\"\n\n@paragraph=\"this is a paragraph\""
0 commit comments