Skip to content

Commit

Permalink
Fixes #66
Browse files Browse the repository at this point in the history
  • Loading branch information
zjhmale committed Apr 4, 2017
1 parent 54c7eab commit 6f5d630
Showing 1 changed file with 25 additions and 2 deletions.
27 changes: 25 additions & 2 deletions src/idris/model.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
const IdrisIdeMode = require('./ide-mode')
const Rx = require('rx-lite')
const Rx = require('rx-lite')
const path = require('path')

class IdrisModel {
constructor() {
Expand Down Expand Up @@ -103,8 +104,30 @@ class IdrisModel {
}
}

changeDirectory(dir) {
return this.interpret(`:cd ${dir}`)
}

load(uri) {
return this.prepareCommand([':load-file', uri])
let dir, cd
if (this.compilerOptions && this.compilerOptions.src) {
dir = this.compilerOptions.src
} else {
dir = path.dirname(uri)
}

if (dir != this.compilerOptions.src) {
this.compilerOptions.src = dir
cd = this.changeDirectory(dir).map((_) => {
return dir
})
} else {
cd = Rx.Observable.of(dir)
}

return cd.flatMap((_) => {
return this.prepareCommand([':load-file', uri])
})
}

getType(word) {
Expand Down

0 comments on commit 6f5d630

Please sign in to comment.