question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Issue: `showHint is not a function`

See original GitHub issue

Hi, I use the following:

  • vue: 2.5.3
  • vue-codemirror 4.0.5
  • vue-electron 1.0.6

With this code:

MyComponent.vue

<template>
  <codemirror
    ref="vueCodemirror"
    v-model="form.query"
    @ready="onCodemirrorReady"
    @input="onCodemirrorInput"
    :options="codemirrorOptions"/>
</template>

<script>
  export default {
    data () {
      return {
        codemirrorOptions: {
          autofocus: true,
          extraKeys: { Ctrl: 'autocomplete' },
          line: true,
          lineNumbers: true,
          mode: 'text/x-mysql',
          styleActiveLine: true
        },
        form: {
          query: 'SELECT * FROM `service.billing`.gridSettings;'
        }
      }
    },
    computed: {
      codemirror () {
        return this.$refs.vueCodemirror.codemirror
      }
    },
    methods: {
      onCodemirrorReady (cm) {
        cm.on('keypress', () => {
          cm.showHint()
        })
      },
      onCodemirrorInput (newQuery) {
        this.form.query = newQuery
      }
    }
  }
</script>

main.js

import Vue from 'vue'
import App from './App'

import VueCodemirror from 'vue-codemirror'
import 'codemirror/addon/hint/show-hint'
import 'codemirror/addon/hint/show-hint.css'
import 'codemirror/addon/hint/sql-hint.js'
import 'codemirror/addon/selection/active-line.js'
import 'codemirror/mode/sql/sql'
import 'codemirror/lib/codemirror.css'
Vue.use(VueCodemirror)

if (!process.env.IS_WEB) Vue.use(require('vue-electron'))

new Vue({
  components: { App },
  template: '<App/>'
}).$mount('#app')

What is Expected?

When I type in the codemirror textarea, showHint function should be called and the hint should be displayed

What is actually happening?

The following error happen: Uncaught TypeError: cm.showHint is not a function

Issue Analytics

  • State:open
  • Created 5 years ago
  • Comments:7 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
KomaGRcommented, Jul 12, 2021

@lihuacai168 You also need to import the show-hint javascript.

import "codemirror/addon/hint/show-hint.js";
0reactions
lihuacai168commented, Jun 28, 2021
Read more comments on GitHub >

github_iconTop Results From Across the Web

CodeMirror custom showHint() call doesn't work - Stack Overflow
Show activity on this post. Attempting to implement a custom showHint call for a spellcheck module. I've followed the docs but calling editor....
Read more >
Why autocomplete on codemirror not work alwayes when I ...
so I write : CodeMirror.commands.autocomplete = function(cm) { CodeMirror.showHint(cm, CodeMirror.hint.anyword); }; var editor = CodeMirror.
Read more >
API Browser autocomplete is broken - Developing with Prismic
showHint is not a function at CodeMirror.commands.autocomplete ... This thread is being monitored as an open ticket in the issue tracker.
Read more >
CodeMirror-Mode-TiddlyWiki5 produces javascript error
showHint is not a function. (In 'e.showHint(i)', 'e.showHint' is undefined) ... I don't know if its your problem but in the past this...
Read more >
It says '1' is not a function, but I believe that the Boolean value ...
//Problem: Hints are shown even when form is valid //Solution: Hide and show them at appropriate times var $password = $("#password"); var ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found