Skip to content

Commit

Permalink
more open strings. Why does this error?
Browse files Browse the repository at this point in the history
...in the browser, but not in the tests
  • Loading branch information
tjvr committed May 12, 2017
1 parent 0365b29 commit 8ccfe43
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
5 changes: 3 additions & 2 deletions editor/mode.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,8 @@ CodeMirror.defineMode('tosh', module.exports = function(cfg, modeCfg) {
try {
completer.feed(line)

// TODO allow partial tokens

} catch (e) {
// TODO avoid lexing again
const lexer = modeCfg.grammar.lexer
Expand Down Expand Up @@ -161,8 +163,7 @@ CodeMirror.defineMode('tosh', module.exports = function(cfg, modeCfg) {

let range = this.line.pop()
if (range.className === 'error' && /^['"]/.test(range.text)) {
stream.match(range.text) // consume
return 'string'
range.className = 'string'
}
if (!stream.match(range.text)) { // consume
throw new Error("Does not match stream")
Expand Down
3 changes: 3 additions & 0 deletions test/mode.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,9 @@ describe('highlight', () => {
MT('open string',
'[error say ][string "]')

MT('open string',
'[error say ][string "foo]')

// make sure I don't try to be too efficient looking for open strings
MT('closed string',
'[s-looks say] [string "foo "] ')
Expand Down

0 comments on commit 8ccfe43

Please sign in to comment.