Misc update

This commit is contained in:
CismonX 2020-10-16 04:16:13 +08:00
parent 7f3178c71e
commit 0a42421055
Signed by: cismonx
GPG Key ID: 3094873E29A482FB
8 changed files with 41 additions and 37 deletions

View File

@ -36,7 +36,7 @@ See `File -> Preferences -> Settings -> Extensions -> Texinfo` for details. The
* If syntax highlighting is not satisfactory, try another color theme where keyword/operator colors are distinct (e.g. Solarized Light/Dark, Monokai).
* Preview content is updated on document save rather than document change.
* For macOS users: Version of preinstalled GNU Texinfo is very old, use a latest one instead. This can be easily done by `brew install texinfo` and change extension setting `texinfo.makeinfo` value.
* For macOS users: Preinstalled GNU Texinfo distribution is very old. Use a latest one instead. This can be easily done by `brew install texinfo` and change extension setting `texinfo.makeinfo` value.
## Future Plans

22
language-config.json Normal file
View File

@ -0,0 +1,22 @@
{
"comments": {
"lineComment": "@c"
},
"brackets": [
["{", "}"],
["[", "]"],
["(", ")"],
["``", "''"]
],
"autoClosingPairs": [
["{", "}"],
["[", "]"],
["(", ")"]
],
"surroundingPairs": [
["{", "}"],
["[", "]"],
["(", ")"],
["`", "'"]
]
}

View File

@ -1,14 +0,0 @@
{
"comments": {
"lineComment": "@c"
},
"brackets": [
["{", "}"]
],
"autoClosingPairs": [
["{", "}"]
],
"surroundingPairs": [
["{", "}"]
]
}

View File

@ -160,15 +160,14 @@
".texinfo",
".txi"
],
"configuration": "./language-configuration.json"
"configuration": "./language-config.json"
}
],
"grammars": [
{
"language": "texinfo",
"scopeName": "text.texinfo",
"path": "./out/texinfo.tmGrammar.json",
"configuration": "./language-configuration.json"
"path": "./out/grammars/texinfo.json"
}
]
}

View File

@ -1,8 +1,8 @@
#!/usr/bin/env sh
mkdir -p ./out
mkdir -p ./out/grammars
# Convert TextMate grammar from CSON to JSON (VSCode cannot recognize CSON ones).
TMGRAMMAR_CSON=./node_modules/language-texinfo/grammars/texinfo.cson
TMGRAMMAR_JSON=./out/texinfo.tmGrammar.json
TMGRAMMAR_JSON=./out/grammars/texinfo.json
cson2json $TMGRAMMAR_CSON > $TMGRAMMAR_JSON

View File

@ -84,7 +84,7 @@ export class FoldingRangeContext {
private bufferedFoldingRanges?: vscode.FoldingRange[];
private commentRange?: [number, number];
private commentRange?: { start: number, end: number };
private headerStart?: number;
@ -99,7 +99,6 @@ export class FoldingRangeContext {
* @param end Ending line number.
*/
private calculateFoldingRanges() {
this.commentRange = undefined;
this.headerStart = undefined;
const closingBlocks = <{ name: string, line: number }[]>[];
for (let idx = this.document.lineCount - 1; idx >= 0; --idx) {
@ -116,7 +115,7 @@ export class FoldingRangeContext {
} else {
const closingBlock = closingBlocks.pop();
if (closingBlock === undefined) {
return;
continue;
}
if (line.substring(1, closingBlock.name.length + 2).trim() === closingBlock.name) {
this.insertRange(idx, closingBlock.line);
@ -126,9 +125,9 @@ export class FoldingRangeContext {
}
}
if (this.commentRange !== undefined) {
this.insertRange(this.commentRange[0], this.commentRange[1], vscode.FoldingRangeKind.Comment);
this.insertRange(this.commentRange.start, this.commentRange.end, vscode.FoldingRangeKind.Comment);
}
return this.bufferedFoldingRanges;
this.commentRange = undefined;
}
private processComment(lineText: string, lineNum: number) {
@ -147,12 +146,12 @@ export class FoldingRangeContext {
return true;
}
if (this.commentRange === undefined) {
this.commentRange = [lineNum, lineNum];
} else if (this.commentRange[0] - 1 === lineNum) {
this.commentRange[0] = lineNum;
this.commentRange = { start: lineNum, end: lineNum };
} else if (this.commentRange.start - 1 === lineNum) {
this.commentRange.start = lineNum;
} else {
this.insertRange(this.commentRange[0], this.commentRange[1], vscode.FoldingRangeKind.Comment);
this.commentRange = [lineNum, lineNum];
this.insertRange(this.commentRange.start, this.commentRange.end, vscode.FoldingRangeKind.Comment);
this.commentRange = { start: lineNum, end: lineNum };
}
return true;
}

View File

@ -7,8 +7,6 @@
import * as vscode from 'vscode';
let options: Options | undefined;
/**
* Fetch extension option values.
*
@ -16,12 +14,14 @@ let options: Options | undefined;
*/
export default class Options {
private static singleton?: Options;
private static get instance() {
return options ?? (options = new Options('texinfo'));
return Options.singleton ?? (Options.singleton = new Options('texinfo'));
}
static clear() {
options = undefined;
Options.singleton = undefined;
}
static get makeinfo() {

View File

@ -126,8 +126,6 @@ export default class Preview {
this.updating = false;
this.updateTitle();
if (this.pendingUpdate) {
this.updateWebview();
}
this.pendingUpdate && this.updateWebview();
}
}