@@ -232,16 +232,21 @@ export class IdrisController {
232232 }
233233 }
234234
235- saveFile ( editor : TextEditor | undefined ) : Promise < void > {
235+ saveFile ( editor : TextEditor | undefined ) : Promise < string > {
236236 if ( editor ) {
237237 const path = editor . getPath ( )
238238 if ( path ) {
239- return editor . save ( )
239+ return editor . save ( ) . then ( ( ) => path )
240240 } else {
241241 const pane = this . getPane ( )
242242 const savePromise = pane . saveActiveItemAs ( )
243243 if ( savePromise ) {
244- return savePromise
244+ const newPath = editor . getPath ( )
245+ if ( newPath ) {
246+ return savePromise . then ( ( ) => newPath )
247+ } else {
248+ return Promise . reject ( )
249+ }
245250 } else {
246251 return Promise . reject ( )
247252 }
@@ -254,8 +259,7 @@ export class IdrisController {
254259 typecheckFile ( ) {
255260 const editor = this . getEditor ( )
256261 if ( editor ) {
257- return this . saveFile ( editor ) . then ( ( ) => {
258- const uri = editor . getPath ( ) as any
262+ return this . saveFile ( editor ) . then ( ( uri ) => {
259263 this . clearMessagePanel ( 'Idris: Typechecking...' )
260264
261265 const successHandler = ( ) => {
@@ -277,8 +281,7 @@ export class IdrisController {
277281 getDocsForWord ( ) {
278282 const editor = this . getEditor ( )
279283 if ( editor ) {
280- return this . saveFile ( editor ) . then ( ( ) => {
281- const uri = editor . getPath ( ) as any
284+ return this . saveFile ( editor ) . then ( ( uri ) => {
282285 const word = Symbol . serializeWord ( getWordUnderCursor ( editor ) )
283286 this . clearMessagePanel (
284287 'Idris: Searching docs for <tt>' + word + '</tt> ...' ,
@@ -313,8 +316,7 @@ export class IdrisController {
313316 getTypeForWord ( ) {
314317 const editor = this . getEditor ( )
315318 if ( editor ) {
316- return this . saveFile ( editor ) . then ( ( ) => {
317- const uri = editor . getPath ( ) as any
319+ return this . saveFile ( editor ) . then ( ( uri ) => {
318320 const word = Symbol . serializeWord ( getWordUnderCursor ( editor ) )
319321 this . clearMessagePanel (
320322 'Idris: Searching type of <tt>' + word + '</tt> ...' ,
@@ -345,8 +347,7 @@ export class IdrisController {
345347 doCaseSplit ( ) {
346348 const editor = this . getEditor ( )
347349 if ( editor ) {
348- return this . saveFile ( editor ) . then ( ( ) => {
349- const uri = editor . getPath ( ) as any
350+ return this . saveFile ( editor ) . then ( ( uri ) => {
350351 const cursor = editor . getLastCursor ( )
351352 const line = cursor . getBufferRow ( )
352353 const word = getWordUnderCursor ( editor )
@@ -386,8 +387,7 @@ export class IdrisController {
386387 doAddClause ( ) {
387388 const editor = this . getEditor ( )
388389 if ( editor ) {
389- return this . saveFile ( editor ) . then ( ( ) => {
390- const uri = editor . getPath ( ) as any
390+ return this . saveFile ( editor ) . then ( ( uri ) => {
391391 const line = editor . getLastCursor ( ) . getBufferRow ( )
392392 // by adding a clause we make sure that the word is
393393 // not treated as a symbol
@@ -431,8 +431,7 @@ export class IdrisController {
431431 doAddProofClause ( ) {
432432 const editor = this . getEditor ( )
433433 if ( editor ) {
434- return this . saveFile ( editor ) . then ( ( ) => {
435- const uri = editor . getPath ( ) as any
434+ return this . saveFile ( editor ) . then ( ( uri ) => {
436435 const line = editor . getLastCursor ( ) . getBufferRow ( )
437436 const word = getWordUnderCursor ( editor )
438437 this . clearMessagePanel ( 'Idris: Add proof clause ...' )
@@ -471,8 +470,7 @@ export class IdrisController {
471470 doMakeWith ( ) {
472471 const editor = this . getEditor ( )
473472 if ( editor ) {
474- return this . saveFile ( editor ) . then ( ( ) => {
475- const uri = editor . getPath ( ) as any
473+ return this . saveFile ( editor ) . then ( ( uri ) => {
476474 const line = editor . getLastCursor ( ) . getBufferRow ( )
477475 const word = getWordUnderCursor ( editor )
478476
@@ -516,8 +514,7 @@ export class IdrisController {
516514 doMakeLemma ( ) {
517515 const editor = this . getEditor ( )
518516 if ( editor ) {
519- return this . saveFile ( editor ) . then ( ( ) => {
520- const uri = editor . getPath ( ) as any
517+ return this . saveFile ( editor ) . then ( ( uri ) => {
521518 let line = editor . getLastCursor ( ) . getBufferRow ( )
522519 const word = getWordUnderCursor ( editor )
523520 this . clearMessagePanel ( 'Idris: Make lemma ...' )
@@ -583,8 +580,7 @@ export class IdrisController {
583580 doMakeCase ( ) {
584581 const editor = this . getEditor ( )
585582 if ( editor ) {
586- return this . saveFile ( editor ) . then ( ( ) => {
587- const uri = editor . getPath ( ) as any
583+ return this . saveFile ( editor ) . then ( ( uri ) => {
588584 const line = editor . getLastCursor ( ) . getBufferRow ( )
589585 const word = getWordUnderCursor ( editor )
590586 this . clearMessagePanel ( 'Idris: Make case ...' )
@@ -621,8 +617,7 @@ export class IdrisController {
621617 showHoles ( ) {
622618 const editor = this . getEditor ( )
623619 if ( editor ) {
624- return this . saveFile ( editor ) . then ( ( ) => {
625- const uri = editor . getPath ( ) as any
620+ return this . saveFile ( editor ) . then ( ( uri ) => {
626621 this . clearMessagePanel ( 'Idris: Searching holes ...' )
627622
628623 const successHandler = ( { msg } : any ) => {
@@ -650,8 +645,7 @@ export class IdrisController {
650645 doProofSearch ( ) {
651646 const editor = this . getEditor ( )
652647 if ( editor ) {
653- return this . saveFile ( editor ) . then ( ( ) => {
654- const uri = editor . getPath ( ) as any
648+ return this . saveFile ( editor ) . then ( ( uri ) => {
655649 const line = editor . getLastCursor ( ) . getBufferRow ( )
656650 const word = getWordUnderCursor ( editor )
657651 this . clearMessagePanel ( 'Idris: Searching proof ...' )
@@ -695,8 +689,7 @@ export class IdrisController {
695689 doBrowseNamespace ( ) {
696690 const editor = this . getEditor ( )
697691 if ( editor ) {
698- return this . saveFile ( editor ) . then ( ( ) => {
699- const uri = editor . getPath ( ) as any
692+ return this . saveFile ( editor ) . then ( ( uri ) => {
700693 let nameSpace = editor . getSelectedText ( )
701694
702695 this . clearMessagePanel (
@@ -749,8 +742,7 @@ export class IdrisController {
749742 printDefinition ( ) {
750743 const editor = this . getEditor ( )
751744 if ( editor ) {
752- return this . saveFile ( editor ) . then ( ( ) => {
753- const uri = editor . getPath ( ) as any
745+ return this . saveFile ( editor ) . then ( ( uri ) => {
754746 const word = Symbol . serializeWord ( getWordUnderCursor ( editor ) )
755747 this . clearMessagePanel (
756748 'Idris: Searching definition of <tt>' + word + '</tt> ...' ,
0 commit comments