mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
prometheus: monaco: do not show automatic suggestions (#41253)
* prometheus: monaco: do not show automatic suggestions * updated comments
This commit is contained in:
parent
a404a311da
commit
ec63b28621
@ -4,7 +4,7 @@ import { GrafanaTheme2 } from '@grafana/data';
|
||||
import { css } from '@emotion/css';
|
||||
import { useLatest } from 'react-use';
|
||||
import { promLanguageDefinition } from 'monaco-promql';
|
||||
import { getCompletionProvider } from './monaco-completion-provider';
|
||||
import { getCompletionProvider, getSuggestOptions } from './monaco-completion-provider';
|
||||
import { Props } from './MonacoQueryFieldProps';
|
||||
import { getOverrideServices } from './getOverrideServices';
|
||||
|
||||
@ -35,6 +35,7 @@ const options: monacoTypes.editor.IStandaloneEditorConstructionOptions = {
|
||||
horizontalScrollbarSize: 0,
|
||||
},
|
||||
scrollBeyondLastLine: false,
|
||||
suggest: getSuggestOptions(),
|
||||
suggestFontSize: 12,
|
||||
wordWrap: 'on',
|
||||
};
|
||||
|
@ -4,6 +4,27 @@ import { getSituation } from './situation';
|
||||
import { getCompletions, DataProvider, CompletionType } from './completions';
|
||||
import { NeverCaseError } from './util';
|
||||
|
||||
export function getSuggestOptions(): monacoTypes.editor.ISuggestOptions {
|
||||
return {
|
||||
// monaco-editor sometimes provides suggestions automatically, i am not
|
||||
// sure based on what, seems to be by analyzing the words already
|
||||
// written.
|
||||
// to try it out:
|
||||
// - enter `go_goroutines{job~`
|
||||
// - have the cursor at the end of the string
|
||||
// - press ctrl-enter
|
||||
// - you will get two suggestions
|
||||
// those were not provided by grafana, they are offered automatically.
|
||||
// i want to remove those. the only way i found is:
|
||||
// - every suggestion-item has a `kind` attribute,
|
||||
// that controls the icon to the left of the suggestion.
|
||||
// - items auto-generated by monaco have `kind` set to `text`.
|
||||
// - we make sure grafana-provided suggestions do not have `kind` set to `text`.
|
||||
// - and then we tell monaco not to show suggestions of kind `text`
|
||||
showWords: false,
|
||||
};
|
||||
}
|
||||
|
||||
function getMonacoCompletionItemKind(type: CompletionType, monaco: Monaco): monacoTypes.languages.CompletionItemKind {
|
||||
switch (type) {
|
||||
case 'DURATION':
|
||||
|
Loading…
Reference in New Issue
Block a user