• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

rajasegar / jarvis / 6900527384

17 Nov 2023 06:08AM UTC coverage: 71.272% (-0.5%) from 71.744%
6900527384

push

github

rajasegar
chore: fix workflow

59 of 92 branches covered (0.0%)

Branch coverage included in aggregate %.

266 of 364 relevant lines covered (73.08%)

8.01 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

53.13
/app/modifiers/code-mirror.js
1
import { modifier } from 'ember-modifier'
2

3
import { EditorView, basicSetup } from 'codemirror'
4
import { StateField, EditorState } from '@codemirror/state'
5
import { javascript } from '@codemirror/lang-javascript'
6
import { json } from '@codemirror/lang-json'
7
import { autocompletion } from '@codemirror/autocomplete'
8

9
function myCompletions(context) {
10
  let word = context.matchBefore(/\w*/)
×
11
  if (word.from == word.to && !context.explicit) return null
×
12
  return {
×
13
    from: word.from,
14
    options: [
15
      { label: 'match', type: 'keyword' },
16
      { label: 'hello', type: 'variable', info: '(World)' },
17
      {
18
        label: 'magic',
19
        type: 'text',
20
        apply: '⠁⭒*.✩.*⭒⠁',
21
        detail: 'macro',
22
      },
23
      {
24
        label: 'j.callExpression',
25
        type: 'function',
26
        info: 'j.callExpression(expression)',
27
        apply: 'j.callExpression()',
28
      },
29
      {
30
        label: '.findFunctionDeclarations',
31
        type: 'function',
32
        info: 'j.findFunctionDeclarations(name?: string)',
33
        apply: "findFunctionDeclarations('foo')",
34
      },
35
    ],
36
  }
37
}
38

39
export default modifier(function codeMirror(
40
  element,
41
  [], // eslint-disable-line
42
  { content, onUpdate, mode }
43
) {
44
  if (!element) {
85!
45
    throw new Error('CodeMirror modifier has no element')
×
46
  }
47

48
  const listenChangesExtension = StateField.define({
85✔
49
    create: () => null,
85✔
50
    update: async (value, transaction) => {
51
      if (transaction.docChanged) {
×
52
        const _input = transaction.newDoc.toString()
×
53
        onUpdate(_input)
×
54
      }
55
      return null
×
56
    },
57
  })
58

59
  const extensions = [
85✔
60
    basicSetup,
61
    listenChangesExtension,
62
    autocompletion({ override: [myCompletions] }),
63
  ]
64

65
  if (mode === 'js') {
85✔
66
    extensions.push(javascript())
70✔
67
  }
68
  if (mode === 'json') {
85✔
69
    extensions.push(json())
14✔
70
  }
71

72
  let startState = EditorState.create({
85✔
73
    doc: content,
74
    extensions,
75
  })
76

77
  const editor = new EditorView({
85✔
78
    state: startState,
79
    parent: element,
80
  })
81

82
  return () => {
85✔
83
    editor.destroy()
85✔
84
  }
85
})
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc