Skip to content

Commit

Permalink
Fix option detection vatlab/sos-notebook#52
Browse files Browse the repository at this point in the history
  • Loading branch information
Bo Peng committed Mar 30, 2018
1 parent 8700611 commit 63918e1
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 18 deletions.
20 changes: 11 additions & 9 deletions src/codemirror-sos.ts
Original file line number Diff line number Diff line change
Expand Up @@ -405,18 +405,20 @@ CodeMirror.defineMode("sos", function(conf: CodeMirror.EditorConfiguration, pars
if (stream.peek() == ',') {
// move next
stream.next();
// , is not the last char, end option line
if (!stream.eol()) {
state.sos_state = null;
state.inner_mode = null;
// , is the last char, continue option line
if (stream.eol()) {
stream.backUp(1);
let it = base_mode.token(stream, state.base_state);
return it ? it + ' sos-option' : null;
}
stream.backUp(1);
let it = base_mode.token(stream, state.base_state);
return it ? it + ' sos-option' : null;
} else {
let it = base_mode.token(stream, state.base_state);
return it ? it + ' sos-option' : null;
} else if (stream.eol()) {
// end of line stops option mode
state.sos_state = null;
state.inner_mode = null;
}
let it = base_mode.token(stream, state.base_state);
return it ? it + ' sos-option' : null;
} else if (state.sos_state && state.sos_state.startsWith("start ")) {
let sl = stream.peek();
let token = base_mode.token(stream, state.base_state);
Expand Down
20 changes: 11 additions & 9 deletions src/sos-mode.js
Original file line number Diff line number Diff line change
Expand Up @@ -411,18 +411,20 @@
if (stream.peek() == ',') {
// move next
stream.next();
// , is not the last char, end option line
if (!stream.eol()) {
state.sos_state = null;
state.inner_mode = null;
// , is the last char, continue option line
if (stream.eol()) {
stream.backUp(1);
let it = base_mode.token(stream, state.base_state);
return it ? it + ' sos-option' : null;
}
stream.backUp(1);
let it = base_mode.token(stream, state.base_state);
return it ? it + ' sos-option' : null;
} else {
let it = base_mode.token(stream, state.base_state);
return it ? it + ' sos-option' : null;
} else if (stream.eol()) {
// end of line stops option mode
state.sos_state = null;
state.inner_mode = null;
}
let it = base_mode.token(stream, state.base_state);
return it ? it + ' sos-option' : null;
} else if (state.sos_state && state.sos_state.startsWith("start ")) {
let sl = stream.peek();
let token = base_mode.token(stream, state.base_state);
Expand Down

0 comments on commit 63918e1

Please sign in to comment.