Skip to content

Commit 06cb36e

Browse files
committed
Add fetching vscode's setting logic
1 parent 3fdfbed commit 06cb36e

File tree

3 files changed

+25
-5
lines changed

3 files changed

+25
-5
lines changed

constant.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
module.exports = {
2-
CLI_SELCTOR_MAX_DISPLAYING_LOG: 5,
32
UI_String: {
43
TYPE_INPUT: 'Type input.',
54
},

extension.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,11 @@ const path = require("path");
33
const findFiles = require("./findFiles");
44
const fs = require("fs");
55
const { getProperties, getInput, getQuickPick } = require("./util");
6-
const { CLI_SELCTOR_MAX_DISPLAYING_LOG, UI_String } = require("./constant");
6+
const { UI_String } = require("./constant");
7+
8+
// fetch setting value from vscode's settings
9+
// See package.json's contributes's configuration
10+
const maxLogDisplayCnt = vscode.workspace.getConfiguration().get('code.replacer.setting');
711

812
/**
913
* @param {vscode.ExtensionContext} context
@@ -60,7 +64,8 @@ const fetchLog = ({ jsonPath, keyName }) => {
6064
const usageLogJson = require(jsonPath)
6165

6266
let displayCnt = 0
63-
const maxDisplayCnt = CLI_SELCTOR_MAX_DISPLAYING_LOG
67+
const maxDisplayCnt = maxLogDisplayCnt
68+
console.log(maxLogDisplayCnt)
6469
const keys = Object.keys(usageLogJson).reverse()
6570
for (const usageLogKey of keys) {
6671
if (usageLogJson[usageLogKey][keyName] && !logs.includes(usageLogJson[usageLogKey][keyName]) && (displayCnt < maxDisplayCnt)) {

package.json

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@
1414
"categories": [
1515
"Other"
1616
],
17+
"keywords": [
18+
"vscode-plugin",
19+
"cope-replacing"
20+
],
1721
"activationEvents": [
1822
"onCommand:code-replacer-vscode-plugin.entry"
1923
],
@@ -22,9 +26,21 @@
2226
"commands": [
2327
{
2428
"command": "code-replacer-vscode-plugin.entry",
25-
"title": "rp"
29+
"title": "rp",
30+
"icon": "image/rp.svg",
31+
"category": "code-replacer entry point"
32+
}
33+
],
34+
"configuration": {
35+
"title": "codeReplacerSetting",
36+
"properties": {
37+
"code.replacer.setting": {
38+
"type": "integer",
39+
"default": 5,
40+
"description": "Please specify up to how many logs you want to display."
41+
}
2642
}
27-
]
43+
}
2844
},
2945
"scripts": {
3046
"lint": "eslint .",

0 commit comments

Comments
 (0)