mirror of
https://github.com/lana-k/sqliteviz.git
synced 2025-12-07 02:28:54 +08:00
show hint in codemirror on Ctrl+Space
This commit is contained in:
@@ -60,4 +60,7 @@ button,
|
|||||||
body {
|
body {
|
||||||
margin: 0;
|
margin: 0;
|
||||||
}
|
}
|
||||||
|
.CodeMirror-hints {
|
||||||
|
z-index: 999 !important;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
@@ -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)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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 }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user