Hide CodeLens if HTML preview is not available.
This commit is contained in:
parent
1bfc52efba
commit
fb89436091
|
@ -45,6 +45,12 @@ export default class Indicator implements vscode.Disposable {
|
||||||
|
|
||||||
private statusBarItem: vscode.StatusBarItem;
|
private statusBarItem: vscode.StatusBarItem;
|
||||||
|
|
||||||
|
private gnuTexinfoAvailable = false;
|
||||||
|
|
||||||
|
get canDisplayPreview() {
|
||||||
|
return this.gnuTexinfoAvailable;
|
||||||
|
}
|
||||||
|
|
||||||
private refresh(editor?: vscode.TextEditor) {
|
private refresh(editor?: vscode.TextEditor) {
|
||||||
if (editor === undefined || editor.document.languageId != 'texinfo') {
|
if (editor === undefined || editor.document.languageId != 'texinfo') {
|
||||||
this.statusBarItem.hide();
|
this.statusBarItem.hide();
|
||||||
|
@ -65,9 +71,11 @@ export default class Indicator implements vscode.Disposable {
|
||||||
} else {
|
} else {
|
||||||
icon = '$(check)';
|
icon = '$(check)';
|
||||||
}
|
}
|
||||||
|
this.gnuTexinfoAvailable = true;
|
||||||
} else {
|
} else {
|
||||||
icon = '$(close)';
|
icon = '$(close)';
|
||||||
tooltip = `GNU Texinfo (${Options.makeinfo}) is not correctly installed or configured.`;
|
tooltip = `GNU Texinfo (${Options.makeinfo}) is not correctly installed or configured.`;
|
||||||
|
this.gnuTexinfoAvailable = false;
|
||||||
}
|
}
|
||||||
this.statusBarItem.text = `${icon} GNU Texinfo ${version}`;
|
this.statusBarItem.text = `${icon} GNU Texinfo ${version}`;
|
||||||
this.statusBarItem.tooltip = tooltip;
|
this.statusBarItem.tooltip = tooltip;
|
||||||
|
|
|
@ -21,6 +21,7 @@
|
||||||
|
|
||||||
import * as vscode from 'vscode';
|
import * as vscode from 'vscode';
|
||||||
import ContextMapping from '../context_mapping';
|
import ContextMapping from '../context_mapping';
|
||||||
|
import Indicator from '../indicator';
|
||||||
import Options from '../options';
|
import Options from '../options';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -30,6 +31,7 @@ export default class CodeLensProvider implements vscode.CodeLensProvider {
|
||||||
|
|
||||||
provideCodeLenses(document: vscode.TextDocument) {
|
provideCodeLenses(document: vscode.TextDocument) {
|
||||||
if (!Options.enableCodeLens) return undefined;
|
if (!Options.enableCodeLens) return undefined;
|
||||||
|
if (!Indicator.instance.canDisplayPreview) return undefined;
|
||||||
return ContextMapping.getDocumentContext(document).foldingRange.nodeValues;
|
return ContextMapping.getDocumentContext(document).foldingRange.nodeValues;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue