Skip to content

Commit

Permalink
Fix calculated kernel for multilanguage
Browse files Browse the repository at this point in the history
- closes nteract#1292
  • Loading branch information
BenRussert committed Apr 13, 2018
1 parent ad0a523 commit 11f576d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
6 changes: 3 additions & 3 deletions lib/store/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ export class Store {
@computed
get kernel(): ?Kernel {
if (!this.filePath) return null;
const kernel = this.kernelMapping.get(this.filePath);
if (!kernel || kernel instanceof Kernel) return kernel;
if (this.grammar) return kernel[this.grammar.name];
const kernelOrMap = this.kernelMapping.get(this.filePath);
if (!kernelOrMap || kernelOrMap instanceof Kernel) return kernelOrMap;
if (this.grammar) return kernelOrMap.get(this.grammar.name);
}

@computed
Expand Down
6 changes: 4 additions & 2 deletions spec/store/index-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -367,15 +367,17 @@ describe("Store", () => {
expect(store.kernel).toBeUndefined();
});

it("should return null if no kernel for file", () => {
it("should return the correct kernel for multilanguage files", () => {
store.editor = { getPath: () => "foo.md" };
const kernel = new Kernel(
new KernelTransport({
display_name: "Python 3",
language: "python"
})
);
store.kernelMapping = new Map([["foo.md", { python: kernel }]]);
store.kernelMapping = new Map([
["foo.md", new Map([["python", kernel]])]
]);
store.grammar = { name: "python" };
expect(store.kernel).toEqual(kernel);
});
Expand Down

0 comments on commit 11f576d

Please sign in to comment.