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
|
@ -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
|
||||
file format restrictions.
|
||||
|
||||
```text
|
||||
assets/texinfo.png
|
||||
```
|
||||
|
||||
They should be treated as if they each contains the following text:
|
||||
|
||||
```text
|
||||
Copyright (C) 2020,2021 CismonX <admin@cismon.net>
|
||||
|
||||
Copying and distribution of this file, with or without modification, are
|
||||
permitted in any medium without royalty, provided the copyright notice and
|
||||
this notice are preserved. This file is offered as-is, without any warranty.
|
||||
```
|
||||
|
||||
## Files from other projects
|
||||
|
||||
|
@ -35,12 +31,19 @@ into a single binary file alongside with vscode-texinfo.
|
|||
|
||||
| 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
|
||||
separate programs.
|
||||
|
||||
| Project | Copyright Holder | License |
|
||||
| - | - | - |
|
||||
| [Visual Studio Code](https://github.com/microsoft/vscode) | 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 |
|
||||
| [Visual Studio Code] | Microsoft Corporation | [MIT](https://github.com/microsoft/vscode/blob/main/LICENSE.txt) |
|
||||
| [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) {
|
||||
const documentContext = this._tryGetDocumentContext(document);
|
||||
if (documentContext === undefined) return;
|
||||
if (documentContext === undefined) {
|
||||
return;
|
||||
}
|
||||
documentContext.foldingRange.clear();
|
||||
documentContext.getPreview()?.updateWebview();
|
||||
}
|
||||
|
|
|
@ -54,7 +54,9 @@ export default class FoldingRangeContext
|
|||
*/
|
||||
update(events: readonly vscode.TextDocumentContentChangeEvent[]) {
|
||||
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';
|
||||
for (const event of events) {
|
||||
// Clear cached folding range when line count changes.
|
||||
|
@ -147,7 +149,9 @@ export default class FoldingRangeContext
|
|||
}
|
||||
// Process block.
|
||||
if (line.startsWith('@end ')) {
|
||||
if (verbatim) continue;
|
||||
if (verbatim) {
|
||||
continue;
|
||||
}
|
||||
const name = line.substring(5).trimRight();
|
||||
if (name === 'verbatim') {
|
||||
verbatim = true;
|
||||
|
@ -193,14 +197,20 @@ export default class FoldingRangeContext
|
|||
private _getLastTextLine(lineNum: number, limit = 3) {
|
||||
for (let idx = lineNum; idx > lineNum - limit; --idx) {
|
||||
const line = this._document.lineAt(idx).text;
|
||||
if (line.startsWith('@node ')) return idx - 1;
|
||||
if (line === '') return idx;
|
||||
if (line.startsWith('@node ')) {
|
||||
return idx - 1;
|
||||
}
|
||||
if (line === '') {
|
||||
return idx;
|
||||
}
|
||||
}
|
||||
return lineNum;
|
||||
}
|
||||
|
||||
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)) {
|
||||
return false;
|
||||
}
|
||||
|
@ -233,7 +243,9 @@ export default class FoldingRangeContext
|
|||
lastLineNum: number,
|
||||
) {
|
||||
const result = lineText.match(FoldingRangeContext._nodeFormat);
|
||||
if (result === null) return false;
|
||||
if (result === null) {
|
||||
return false;
|
||||
}
|
||||
// Node identifier.
|
||||
if (result[1] !== undefined) {
|
||||
this._nodes.push(new vscode.CodeLens(lineNumToRange(lineNum), {
|
||||
|
|
|
@ -127,7 +127,9 @@ export default class PreviewContext
|
|||
* preview with code lens.
|
||||
*/
|
||||
private get _script() {
|
||||
if (!this._globalContext.options.enableCodeLens) return undefined;
|
||||
if (!this._globalContext.options.enableCodeLens) {
|
||||
return undefined;
|
||||
}
|
||||
return "window.addEventListener('message', event => {" +
|
||||
"const message = event.data;" +
|
||||
"switch (message.command) {" +
|
||||
|
|
|
@ -1156,7 +1156,9 @@ export default class CompletionItemProvider
|
|||
this._oldOptions = newOptions;
|
||||
this._completionItems = undefined;
|
||||
}
|
||||
if (position.character === 1) return this._getCompletionItems();
|
||||
if (position.character === 1) {
|
||||
return this._getCompletionItems();
|
||||
}
|
||||
// Check whether the '@' character is escaped.
|
||||
const secondCharBeforeWord = new vscode.Range(
|
||||
position.translate(0, -2),
|
||||
|
|
Loading…
Reference in New Issue