Refactor code.
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
This commit is contained in:
parent
c111ec89a0
commit
26c8d32129
|
@ -1,9 +1,9 @@
|
||||||
<!--
|
<!--
|
||||||
Copyright (C) 2021 CismonX <admin@cismon.net>
|
Copyright (C) 2021 CismonX <admin@cismon.net>
|
||||||
|
|
||||||
Copying and distribution of this file, with or without modification, are
|
Copying and distribution of this file, with or without modification, are
|
||||||
permitted in any medium without royalty, provided the copyright notice and
|
permitted in any medium without royalty, provided the copyright notice and
|
||||||
this notice are preserved. This file is offered as-is, without any warranty.
|
this notice are preserved. This file is offered as-is, without any warranty.
|
||||||
-->
|
-->
|
||||||
|
|
||||||
# License Notice
|
# License Notice
|
||||||
|
@ -13,19 +13,15 @@ this notice are preserved. This file is offered as-is, without any warranty.
|
||||||
Project files listed below cannot carry a license notice by themselves, due to
|
Project files listed below cannot carry a license notice by themselves, due to
|
||||||
file format restrictions.
|
file format restrictions.
|
||||||
|
|
||||||
```text
|
assets/texinfo.png
|
||||||
assets/texinfo.png
|
|
||||||
```
|
|
||||||
|
|
||||||
They should be treated as if they each contains the following text:
|
They should be treated as if they each contains the following text:
|
||||||
|
|
||||||
```text
|
Copyright (C) 2020,2021 CismonX <admin@cismon.net>
|
||||||
Copyright (C) 2020,2021 CismonX <admin@cismon.net>
|
|
||||||
|
|
||||||
Copying and distribution of this file, with or without modification, are
|
Copying and distribution of this file, with or without modification, are
|
||||||
permitted in any medium without royalty, provided the copyright notice and
|
permitted in any medium without royalty, provided the copyright notice and
|
||||||
this notice are preserved. This file is offered as-is, without any warranty.
|
this notice are preserved. This file is offered as-is, without any warranty.
|
||||||
```
|
|
||||||
|
|
||||||
## Files from other projects
|
## Files from other projects
|
||||||
|
|
||||||
|
@ -33,14 +29,21 @@ Source code from the projects listed below are **not** part of vscode-texinfo.
|
||||||
However, when building the project, they are downloaded, compiled, and packaged
|
However, when building the project, they are downloaded, compiled, and packaged
|
||||||
into a single binary file alongside with vscode-texinfo.
|
into a single binary file alongside with vscode-texinfo.
|
||||||
|
|
||||||
| Project | Copyright Holder | License |
|
| Project | Copyright Holder | License |
|
||||||
| - | - | - |
|
| - | - | - |
|
||||||
| [Texinfo syntax highlighting](https://github.com/Alhadis/language-texinfo) | John Gardner | [ISC](https://github.com/Alhadis/language-texinfo/blob/master/LICENSE.md) |
|
| [Texinfo syntax highlighting] | John Gardner | [ISC](https://github.com/Alhadis/language-texinfo/blob/master/LICENSE.md) |
|
||||||
|
|
||||||
The following projects are required during runtime of vscode-texinfo, but as
|
The following projects are required during runtime of vscode-texinfo, but as
|
||||||
separate programs.
|
separate programs.
|
||||||
|
|
||||||
| Project | Copyright Holder | License |
|
| Project | Copyright Holder | License |
|
||||||
| - | - | - |
|
| - | - | - |
|
||||||
| [Visual Studio Code](https://github.com/microsoft/vscode) | Microsoft Corporation | [MIT](https://github.com/microsoft/vscode/blob/main/LICENSE.txt) |
|
| [Visual Studio Code] | Microsoft Corporation | [MIT](https://github.com/microsoft/vscode/blob/main/LICENSE.txt) |
|
||||||
| [GNU Texinfo](https://www.gnu.org/software/texinfo) | Free Software Foundation | [GPL-3.0](https://git.savannah.gnu.org/cgit/texinfo.git/tree/COPYING)-or-later |
|
| [GNU Texinfo] | Free Software Foundation | [GPL-3.0](https://git.savannah.gnu.org/cgit/texinfo.git/tree/COPYING)-or-later |
|
||||||
|
|
||||||
|
|
||||||
|
<!-- Reference Links -->
|
||||||
|
|
||||||
|
[Texinfo syntax highlighting]: https://github.com/Alhadis/language-texinfo
|
||||||
|
[Visual Studio Code]: https://github.com/microsoft/vscode
|
||||||
|
[GNU Texinfo]: https://www.gnu.org/software/texinfo
|
||||||
|
|
|
@ -97,7 +97,9 @@ export default class ContextMapping implements vscode.Disposable
|
||||||
|
|
||||||
private _onDocumentSave(document: vscode.TextDocument) {
|
private _onDocumentSave(document: vscode.TextDocument) {
|
||||||
const documentContext = this._tryGetDocumentContext(document);
|
const documentContext = this._tryGetDocumentContext(document);
|
||||||
if (documentContext === undefined) return;
|
if (documentContext === undefined) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
documentContext.foldingRange.clear();
|
documentContext.foldingRange.clear();
|
||||||
documentContext.getPreview()?.updateWebview();
|
documentContext.getPreview()?.updateWebview();
|
||||||
}
|
}
|
||||||
|
|
|
@ -54,7 +54,9 @@ export default class FoldingRangeContext
|
||||||
*/
|
*/
|
||||||
update(events: readonly vscode.TextDocumentContentChangeEvent[]) {
|
update(events: readonly vscode.TextDocumentContentChangeEvent[]) {
|
||||||
this._contentMayChange = true;
|
this._contentMayChange = true;
|
||||||
if (this._foldingRanges === undefined) return false;
|
if (this._foldingRanges === undefined) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
const eol = this._document.eol === vscode.EndOfLine.LF ? '\n' : '\r\n';
|
const eol = this._document.eol === vscode.EndOfLine.LF ? '\n' : '\r\n';
|
||||||
for (const event of events) {
|
for (const event of events) {
|
||||||
// Clear cached folding range when line count changes.
|
// Clear cached folding range when line count changes.
|
||||||
|
@ -147,7 +149,9 @@ export default class FoldingRangeContext
|
||||||
}
|
}
|
||||||
// Process block.
|
// Process block.
|
||||||
if (line.startsWith('@end ')) {
|
if (line.startsWith('@end ')) {
|
||||||
if (verbatim) continue;
|
if (verbatim) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
const name = line.substring(5).trimRight();
|
const name = line.substring(5).trimRight();
|
||||||
if (name === 'verbatim') {
|
if (name === 'verbatim') {
|
||||||
verbatim = true;
|
verbatim = true;
|
||||||
|
@ -193,14 +197,20 @@ export default class FoldingRangeContext
|
||||||
private _getLastTextLine(lineNum: number, limit = 3) {
|
private _getLastTextLine(lineNum: number, limit = 3) {
|
||||||
for (let idx = lineNum; idx > lineNum - limit; --idx) {
|
for (let idx = lineNum; idx > lineNum - limit; --idx) {
|
||||||
const line = this._document.lineAt(idx).text;
|
const line = this._document.lineAt(idx).text;
|
||||||
if (line.startsWith('@node ')) return idx - 1;
|
if (line.startsWith('@node ')) {
|
||||||
if (line === '') return idx;
|
return idx - 1;
|
||||||
|
}
|
||||||
|
if (line === '') {
|
||||||
|
return idx;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return lineNum;
|
return lineNum;
|
||||||
}
|
}
|
||||||
|
|
||||||
private _processComment(lineText: string, lineNum: number) {
|
private _processComment(lineText: string, lineNum: number) {
|
||||||
if (!lineText.startsWith('@c')) return false;
|
if (!lineText.startsWith('@c')) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
if (lineText.charAt(2) != ' ' && !lineText.startsWith('omment ', 2)) {
|
if (lineText.charAt(2) != ' ' && !lineText.startsWith('omment ', 2)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -233,7 +243,9 @@ export default class FoldingRangeContext
|
||||||
lastLineNum: number,
|
lastLineNum: number,
|
||||||
) {
|
) {
|
||||||
const result = lineText.match(FoldingRangeContext._nodeFormat);
|
const result = lineText.match(FoldingRangeContext._nodeFormat);
|
||||||
if (result === null) return false;
|
if (result === null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
// Node identifier.
|
// Node identifier.
|
||||||
if (result[1] !== undefined) {
|
if (result[1] !== undefined) {
|
||||||
this._nodes.push(new vscode.CodeLens(lineNumToRange(lineNum), {
|
this._nodes.push(new vscode.CodeLens(lineNumToRange(lineNum), {
|
||||||
|
|
|
@ -127,7 +127,9 @@ export default class PreviewContext
|
||||||
* preview with code lens.
|
* preview with code lens.
|
||||||
*/
|
*/
|
||||||
private get _script() {
|
private get _script() {
|
||||||
if (!this._globalContext.options.enableCodeLens) return undefined;
|
if (!this._globalContext.options.enableCodeLens) {
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
return "window.addEventListener('message', event => {" +
|
return "window.addEventListener('message', event => {" +
|
||||||
"const message = event.data;" +
|
"const message = event.data;" +
|
||||||
"switch (message.command) {" +
|
"switch (message.command) {" +
|
||||||
|
|
|
@ -1156,7 +1156,9 @@ export default class CompletionItemProvider
|
||||||
this._oldOptions = newOptions;
|
this._oldOptions = newOptions;
|
||||||
this._completionItems = undefined;
|
this._completionItems = undefined;
|
||||||
}
|
}
|
||||||
if (position.character === 1) return this._getCompletionItems();
|
if (position.character === 1) {
|
||||||
|
return this._getCompletionItems();
|
||||||
|
}
|
||||||
// Check whether the '@' character is escaped.
|
// Check whether the '@' character is escaped.
|
||||||
const secondCharBeforeWord = new vscode.Range(
|
const secondCharBeforeWord = new vscode.Range(
|
||||||
position.translate(0, -2),
|
position.translate(0, -2),
|
||||||
|
|
Loading…
Reference in New Issue