mirror of
https://github.com/estruyf/vscode-front-matter.git
synced 2026-03-28 17:42:40 +01:00
Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
fdfdfda6ce | ||
|
|
f016ae27ec |
@@ -1,5 +1,9 @@
|
||||
# Change Log
|
||||
|
||||
## [2.4.1] - 2020-08-16
|
||||
|
||||
- Better editor highlighting functionality
|
||||
|
||||
## [2.4.0] - 2020-08-16
|
||||
|
||||
- [#21](https://github.com/estruyf/vscode-front-matter/issues/21): Folding provider for Front Matter implemented
|
||||
|
||||
2
package-lock.json
generated
2
package-lock.json
generated
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "vscode-front-matter",
|
||||
"version": "2.4.0",
|
||||
"version": "2.4.1",
|
||||
"lockfileVersion": 1,
|
||||
"requires": true,
|
||||
"dependencies": {
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
"displayName": "Front Matter",
|
||||
"description": "Simplifies working with front matter of your articles. Useful extension when you are using a static site generator like: Hugo, Jekyll, Hexo, NextJs, Gatsby, and many more...",
|
||||
"icon": "assets/front-matter.png",
|
||||
"version": "2.4.0",
|
||||
"version": "2.4.1",
|
||||
"preview": false,
|
||||
"publisher": "eliostruyf",
|
||||
"galleryBanner": {
|
||||
|
||||
@@ -125,6 +125,9 @@ export async function activate({ subscriptions, extensionUri }: vscode.Extension
|
||||
editDebounce = debounceCallback();
|
||||
subscriptions.push(vscode.workspace.onDidChangeTextDocument(triggerFileChange));
|
||||
|
||||
// Listener for setting changes
|
||||
subscriptions.push(vscode.workspace.onDidChangeConfiguration(MarkdownFoldingProvider.triggerHighlighting));
|
||||
|
||||
// Subscribe all commands
|
||||
subscriptions.push(
|
||||
insertTags,
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { workspace } from 'vscode';
|
||||
import { TextEditorDecorationType, workspace } from 'vscode';
|
||||
import { CancellationToken, FoldingContext, FoldingRange, FoldingRangeKind, FoldingRangeProvider, Range, TextDocument, window, Position } from 'vscode';
|
||||
import { CONFIG_KEY, SETTINGS_CONTENT_FRONTMATTER_HIGHLIGHT } from '../constants';
|
||||
import { FrontMatterDecorationProvider } from './FrontMatterDecorationProvider';
|
||||
@@ -7,6 +7,7 @@ export class MarkdownFoldingProvider implements FoldingRangeProvider {
|
||||
private static start: number | null = null;
|
||||
private static end: number | null = null;
|
||||
private static endLine: number | null = null;
|
||||
private static decType: TextEditorDecorationType | null = null;
|
||||
|
||||
public async provideFoldingRanges(document: TextDocument, context: FoldingContext, token: CancellationToken): Promise<FoldingRange[]> {
|
||||
const ranges: FoldingRange[] = [];
|
||||
@@ -48,9 +49,13 @@ export class MarkdownFoldingProvider implements FoldingRangeProvider {
|
||||
if (MarkdownFoldingProvider.start !== null && MarkdownFoldingProvider.end !== null && MarkdownFoldingProvider.endLine !== null) {
|
||||
const range = new Range(new Position(MarkdownFoldingProvider.start, 0), new Position(MarkdownFoldingProvider.end, MarkdownFoldingProvider.endLine));
|
||||
|
||||
if (MarkdownFoldingProvider.decType !== null) {
|
||||
MarkdownFoldingProvider.decType.dispose();
|
||||
}
|
||||
|
||||
if (fmHighlight) {
|
||||
const decoration = new FrontMatterDecorationProvider().get();
|
||||
window.activeTextEditor?.setDecorations(decoration, [range]);
|
||||
MarkdownFoldingProvider.decType = new FrontMatterDecorationProvider().get();
|
||||
window.activeTextEditor?.setDecorations(MarkdownFoldingProvider.decType, [range]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -442,11 +442,6 @@ export class ExplorerView implements WebviewViewProvider, Disposable {
|
||||
const config = workspace.getConfiguration(CONFIG_KEY);
|
||||
await config.update(SETTINGS_CONTENT_FRONTMATTER_HIGHLIGHT, autoUpdate);
|
||||
this.getSettings();
|
||||
|
||||
if (ArticleHelper.isMarkdownFile()) {
|
||||
// To unset the decorations, we need to reload the whole document/instance
|
||||
commands.executeCommand(`workbench.action.reloadWindow`);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user