Skip to content

Commit

Permalink
Merge pull request #154 from cs-education/syntax_error_fix
Browse files Browse the repository at this point in the history
Add modelist to build and denote supported syntax modes
  • Loading branch information
jwchang0206 committed Apr 26, 2016
2 parents 571ec8e + e3637bf commit fdbd11c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
2 changes: 2 additions & 0 deletions gulp-tasks/build-js.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,9 @@ const requireJsOptimizerFilesConfig = [
'components/compiler-state-label/compiler-state-label',
'components/not-found-page/not-found-page',
'components/file-browser/file-browser',
'ace/ext/modelist',
'ace/mode/c_cpp',
'ace/mode/makefile',
'ace/theme/monokai',
'ace/theme/terminal',
'ace/theme/tomorrow',
Expand Down
6 changes: 6 additions & 0 deletions src/components/editor/editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ class Editor {

this.availableThemes = ko.observableArray(['monokai', 'terminal', 'tomorrow', 'xcode']);

this.supportedAceModes = ['ace/mode/c_cpp','ace/mode/makefile'];

this.annotations = params.annotations;
this.keyboardShortcuts = params.keyboardShortcuts;

Expand Down Expand Up @@ -259,6 +261,10 @@ class Editor {

this.filename = filename;
var mode = this.modelist.getModeForPath(filename).mode;

if(this.supportedAceModes.indexOf(mode) < 0)
mode = 'ace/mode/text';

this.aceEditor.session.setMode(mode);

return;
Expand Down

0 comments on commit fdbd11c

Please sign in to comment.