Skip to content

Commit a07fed5

Browse files
Few bug fixes
1 parent 6132b7b commit a07fed5

File tree

4 files changed

+14
-5
lines changed

4 files changed

+14
-5
lines changed

FSharp.Atom.sln

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ EndProject
1111
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{176D5273-0AF5-44A6-894C-F057F13F3391}"
1212
ProjectSection(SolutionItems) = preProject
1313
src\atom-bindings.fsx = src\atom-bindings.fsx
14-
src\autocomplete.fsx = src\autocomplete.fsx
14+
src\core.fsx = src\core.fsx
1515
src\funscript-atom.fsx = src\funscript-atom.fsx
1616
EndProjectSection
1717
EndProject

Test/Script.fsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,4 @@ let t = match foobar with
1212
| 1 -> 0
1313

1414
let t = System.IO.Directory
15-
let a = System.IO.D
15+
let a = System.IO.DriveInfo.GetDrives()

src/atom-bindings.fsx

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,12 @@ module Promise =
2323
module JS =
2424
[<JSEmitInline("({1}[{0}])")>]
2525
let getProperty<'T> (prop:string) (o:obj) : 'T = failwith "JS"
26+
27+
[<JSEmitInline("({0}[{1}] != undefined)")>]
28+
let isPropertyDefined (o: obj) (key: string) : bool = failwith "JS"
29+
30+
[<JSEmitInline("(global[{0}] != undefined)")>]
31+
let isGloballyDefined (key: string) : bool = failwith "never"
32+
33+
[<JSEmitInline("({0} != undefined)")>]
34+
let isDefined (o: obj) : bool = failwith "never"

src/core.fsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ open FunScript.TypeScript.text_buffer
1010
#load "funscript-atom.fsx"
1111
#load "atom-bindings.fsx"
1212

13-
//open Atom
13+
open Atom
1414
//open Atom.Editor
1515
//open Atom.Promise
1616

@@ -95,7 +95,7 @@ module AutocompleteHandler =
9595
service |> AutocompleteService.ask str 2 cb
9696

9797
let parseEditor (editor : IEditor) cb service =
98-
if editor.getGrammar().name = "F#" then
98+
if JS.isDefined editor && JS.isPropertyDefined editor "getGrammar" && editor.getGrammar().name = "F#" then
9999
let path = editor.buffer.file.path
100100
let text = editor.getText()
101101
let action (s : string) =
@@ -214,7 +214,7 @@ module Views =
214214
|> jq
215215

216216
let hadnleEditorChange (panel : IPanel) (editor : AtomCore.IEditor) =
217-
if editor.getGrammar().name = "F#" then panel.show() else panel.hide()
217+
if JS.isDefined editor && JS.isPropertyDefined editor "getGrammar" && editor.getGrammar().name = "F#" then panel.show() else panel.hide()
218218

219219
type PanelOptions =
220220
{ item: JQuery;

0 commit comments

Comments
 (0)