1
0
mirror of https://github.com/lana-k/sqliteviz.git synced 2025-12-06 18:18:53 +08:00

show hint in codemirror on Ctrl+Space

This commit is contained in:
lana-k
2021-05-04 16:33:37 +02:00
parent cc483f4720
commit 5ab19c3fae
3 changed files with 11 additions and 2 deletions

View File

@@ -60,4 +60,7 @@ button,
body { body {
margin: 0; margin: 0;
} }
.CodeMirror-hints {
z-index: 999 !important;
}
</style> </style>

View File

@@ -33,6 +33,10 @@ const hintOptions = {
alignWithWord: false alignWithWord: false
} }
export function showHintOnDemand (editor) {
CM.showHint(editor, getHints, hintOptions)
}
export default function showHint (editor) { export default function showHint (editor) {
// Don't show autocomplete after a space or semicolon or in string literals // Don't show autocomplete after a space or semicolon or in string literals
const token = editor.getTokenAt(editor.getCursor()) const token = editor.getTokenAt(editor.getCursor())
@@ -41,5 +45,6 @@ export default function showHint (editor) {
if (tokenType === 'string' || !ch || ch === ' ' || ch === ';') { if (tokenType === 'string' || !ch || ch === ' ' || ch === ';') {
return return
} }
CM.showHint(editor, getHints, hintOptions) CM.showHint(editor, getHints, hintOptions)
} }

View File

@@ -5,7 +5,7 @@
</template> </template>
<script> <script>
import showHint from './hint' import showHint, { showHintOnDemand } from './hint'
import { debounce } from 'debounce' import { debounce } from 'debounce'
import { codemirror } from 'vue-codemirror' import { codemirror } from 'vue-codemirror'
import 'codemirror/lib/codemirror.css' import 'codemirror/lib/codemirror.css'
@@ -29,7 +29,8 @@ export default {
lineNumbers: true, lineNumbers: true,
line: true, line: true,
autofocus: true, autofocus: true,
autoRefresh: true autoRefresh: true,
extraKeys: { 'Ctrl-Space': showHintOnDemand }
} }
} }
}, },