Skip to content

Commit

Permalink
Merge pull request #21 from lz37/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
lz37 authored Dec 25, 2023
2 parents ef8dcbb + 507bcf1 commit 8e02d0b
Show file tree
Hide file tree
Showing 18 changed files with 3,463 additions and 13 deletions.
7 changes: 7 additions & 0 deletions .envrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Automatically sets up your devbox environment whenever you cd into this
# directory via our direnv integration:

eval "$(devbox generate direnv --print-envrc)"

# check out https://www.jetpack.io/devbox/docs/ide_configuration/direnv/
# for more details
2 changes: 1 addition & 1 deletion .github/workflows/vsce.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [18.13.0]
node-version: [18.17.1]
steps:
- uses: actions/checkout@v3
- uses: pnpm/action-setup@v2
Expand Down
1 change: 0 additions & 1 deletion .nvmrc

This file was deleted.

11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
## [1.4.8](https://github.com/lz37/noveler/compare/v1.4.5...v1.4.8) (2023-12-25)


### Bug Fixes

* **csvreader.ts:** solve bug of failing to show default highlight when no csv settings ([ac29c89](https://github.com/lz37/noveler/commit/ac29c89d8437c111fe99077433c8a55b2e71d231))
* stricten the onChangeConf hook ([20b40e7](https://github.com/lz37/noveler/commit/20b40e77ede217c8bfbe54a2cd41edd8dd5fd8bd))
* word count bug ([e43f117](https://github.com/lz37/noveler/commit/e43f117b41c6c8dd8b6a3de6da87a7834d9c5c73))



## [1.4.7](https://github.com/lz37/noveler/compare/v1.4.5...v1.4.7) (2023-07-28)


Expand Down
3 changes: 3 additions & 0 deletions devbox.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"packages": ["nodePackages.pnpm@latest", "[email protected]"]
}
45 changes: 45 additions & 0 deletions devbox.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
{
"lockfile_version": "1",
"packages": {
"nodePackages.pnpm@latest": {
"last_modified": "2023-12-13T22:54:10Z",
"resolved": "github:NixOS/nixpkgs/fd04bea4cbf76f86f244b9e2549fca066db8ddff#nodePackages.pnpm",
"source": "devbox-search",
"version": "8.10.5",
"systems": {
"aarch64-darwin": {
"store_path": "/nix/store/mp0ppa9xhaaqs398r5hpvhnbwpc9mpfw-pnpm-8.10.5"
},
"aarch64-linux": {
"store_path": "/nix/store/vjvri6p42iind1dj500jhzh1lai3972r-pnpm-8.10.5"
},
"x86_64-darwin": {
"store_path": "/nix/store/kq84mdjh9ycsvnkj1dmgiz8ks6fyivqk-pnpm-8.10.5"
},
"x86_64-linux": {
"store_path": "/nix/store/y3mxy318cr8cl26saysfwqbxbcwb31lb-pnpm-8.10.5"
}
}
},
"[email protected]": {
"last_modified": "2023-09-15T06:49:28Z",
"resolved": "github:NixOS/nixpkgs/46688f8eb5cd6f1298d873d4d2b9cf245e09e88e#nodejs_18",
"source": "devbox-search",
"version": "18.17.1",
"systems": {
"aarch64-darwin": {
"store_path": "/nix/store/nk77k4d3fj6i2fbd9nmqm5bqqdjy3knb-nodejs-18.17.1"
},
"aarch64-linux": {
"store_path": "/nix/store/kgzwqvksqjms49jlfz9nzz2cjxsh8ani-nodejs-18.17.1"
},
"x86_64-darwin": {
"store_path": "/nix/store/x01bx6r10w0835xmhxyjqn9khamdh9pj-nodejs-18.17.1"
},
"x86_64-linux": {
"store_path": "/nix/store/fg86njc0q2djbyfaqvnaq7x0khpc6sf4-nodejs-18.17.1"
}
}
}
}
}
2 changes: 1 addition & 1 deletion docs/description.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
## bug修复

- 修复了无csv文件时默认高亮不生效的bug
- 修复了配置文件被重复读取的部分问题(针对大文件优化)
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "noveler",
"displayName": "Noveler",
"description": "一个在 vscode 上辅助码中文小说的插件",
"version": "1.4.7",
"version": "1.4.8",
"author": "zerozawa",
"publisher": "zerozawa",
"license": "GPL-3.0",
Expand Down
10 changes: 8 additions & 2 deletions packages/extension/src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,11 @@ import * as panel from '@/modules/webviews/Panel'
import { Commands } from 'common/types'
import * as os from 'os'

export let initing = false

// this method is called when vs code is activated
export const activate = async (context: vscode.ExtensionContext) => {
initing = true
const editor = vscode.window.activeTextEditor
await confHandler.askForPlaintextConf()
// ------------------ setcontext ------------------
Expand Down Expand Up @@ -56,6 +59,9 @@ export const activate = async (context: vscode.ExtensionContext) => {
diagnostic.onChangeConfDocument,
)
// ------------------ extension-init ------------------
await vscode.commands.executeCommand(Commands.ReloadCSV)
await vscode.commands.executeCommand(Commands.ReloadTXT)
CSVReader.loadFile()
TXTReader.loadFile()
initing = false
}

// export const deactivate = () => {}
5 changes: 4 additions & 1 deletion packages/extension/src/modules/Completion.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ export const updateProvider = () => {
}
const items: vscode.CompletionItem[] = []
keys.forEach(({ desc, kind, prefix }, key) => {
console.log(key)
const item = new vscode.CompletionItem(`${prefix}${key}`, kind)
item.command = command
item.insertText = key
Expand Down Expand Up @@ -89,3 +88,7 @@ export const deletePrefixCommand = vscode.commands.registerCommand(
})
},
)

export const deactivate = () => {
if (provider) provider.dispose()
}
11 changes: 11 additions & 0 deletions packages/extension/src/modules/Decoration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {
ICustomHighlightConfMap,
IDealedCustomHighlightConfMap,
} from 'common/types'
import { initing } from '@/extension'

const targetFiles = ['plaintext', 'markdown']

Expand Down Expand Up @@ -40,6 +41,7 @@ export const reloadConf = (extConf?: ICustomHighlightConfMap) => {

export const onChangeConf = vscode.workspace.onDidChangeConfiguration(
(event) => {
if (initing) return
if (!event.affectsConfiguration('noveler')) return
reloadConf()
},
Expand Down Expand Up @@ -154,3 +156,12 @@ export const triggerUpdateDecorations = (activeEditor: vscode.TextEditor) => {
if (!targetFiles.includes(activeEditor.document.languageId)) return
updateDecorations(activeEditor)
}

export const deactivate = () => {
// 注销掉高亮
const editor = vscode.window.activeTextEditor
destroyHovers()
if (editor) {
destroyDecorations(editor)
}
}
2 changes: 2 additions & 0 deletions packages/extension/src/modules/Diagnostic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import * as vscode from 'vscode'
import * as confHandler from '@/modules/ConfigHandler'
import { getAbsolutePaths } from 'common/utils'
import { DiagnosticSeverityKeys, Commands } from 'common/types'
import { initing } from '@/extension'

const targetFiles = ['plaintext', 'markdown']

Expand All @@ -22,6 +23,7 @@ export const onChangeDocument = vscode.workspace.onDidChangeTextDocument(

export const onChangConf = vscode.workspace.onDidChangeConfiguration(
async (event) => {
if (initing) return
if (event.affectsConfiguration('noveler')) {
await vscode.commands.executeCommand(Commands.ReloadTXT)
}
Expand Down
5 changes: 4 additions & 1 deletion packages/extension/src/modules/StatusBar.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import * as vscode from 'vscode'
import * as confHandler from '@/modules/ConfigHandler'
import { StatusItem } from 'common/types'
import { initing } from '@/extension'

const targetFiles = ['plaintext', 'markdown']

Expand Down Expand Up @@ -138,6 +139,8 @@ export const changeEditor = vscode.window.onDidChangeActiveTextEditor(
},
)

export const changeConf = vscode.workspace.onDidChangeConfiguration(() => {
export const changeConf = vscode.workspace.onDidChangeConfiguration((event) => {
if (initing) return
if (!event.affectsConfiguration('noveler')) return
updateConf()
})
13 changes: 9 additions & 4 deletions packages/extension/src/modules/reader/CSVReader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
Commands,
ICustomHighlightConfMap,
} from 'common/types'
import { initing } from '@/extension'

let conf: CSVOptionMap | undefined = undefined
let highlightConf: ICustomHighlightConfMap | undefined = undefined
Expand Down Expand Up @@ -108,7 +109,7 @@ const handleCSV = async (csvOpt: CSVOptions) => {
}
}

const loadFile = async () => {
export const loadFile = async () => {
try {
updateConf()
} catch (error) {
Expand Down Expand Up @@ -138,6 +139,10 @@ export const reloadCommand = vscode.commands.registerCommand(
},
)

export const onChangeConf = vscode.workspace.onDidChangeConfiguration(() => {
vscode.commands.executeCommand(Commands.ReloadCSV)
})
export const onChangeConf = vscode.workspace.onDidChangeConfiguration(
(event) => {
if (initing) return
if (!event.affectsConfiguration('noveler')) return
vscode.commands.executeCommand(Commands.ReloadCSV)
},
)
2 changes: 1 addition & 1 deletion packages/extension/src/modules/reader/TXTReader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ const handleTxt = async (path: string) => {
return words
}

const loadFile = async () => {
export const loadFile = async () => {
try {
updateConf()
} catch (error) {
Expand Down
2 changes: 2 additions & 0 deletions packages/extension/src/modules/webviews/Preview.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import * as vscode from 'vscode'
import * as confHandler from '@/modules/ConfigHandler'
import { PreviewDto, PreviewExtRecDto, Commands, IConfig } from 'common/types'
import { createWebviewHtml } from 'common/utils'
import { initing } from '@/extension'

const targetFiles = ['plaintext']

Expand Down Expand Up @@ -150,6 +151,7 @@ export const provider = (context: vscode.ExtensionContext) => {
},
),
onChangeConf: vscode.workspace.onDidChangeConfiguration(async (event) => {
if (initing) return
if (!event.affectsConfiguration('noveler')) {
return
}
Expand Down
10 changes: 10 additions & 0 deletions test/folder3/.vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,14 @@
"editor.autoIndent": "none",
"editor.wordWrap": "bounded"
},
"noveler.confCSVFiles": [
{
"path": "简码提示.csv",
"hoverKey": "hoverKey",
"key": "key",
"decorationRenderOptions": {
"color": "#9e952f"
}
}
]
}
Loading

0 comments on commit 8e02d0b

Please sign in to comment.