@codingame/monaco-vscode-quickaccess-service-override 1.83.16 → 1.85.0-next.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +3 -3
- package/vscode/src/vs/platform/quickinput/browser/commandsQuickAccess.js +29 -9
- package/vscode/src/vs/workbench/browser/actions/quickAccessActions.js +1 -1
- package/vscode/src/vs/workbench/contrib/quickaccess/browser/commandsQuickAccess.js +8 -2
- package/vscode/src/vs/workbench/contrib/quickaccess/browser/viewQuickAccess.js +1 -1
- package/vscode/src/vs/workbench/services/quickinput/browser/quickInputService.js +12 -3
- package/vscode/src/vs/base/common/tfIdf.js +0 -138
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatActions.js +0 -3
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@codingame/monaco-vscode-quickaccess-service-override",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.85.0-next.1",
|
|
4
4
|
"keywords": [],
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "CodinGame",
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
"module": "index.js",
|
|
19
19
|
"types": "index.d.ts",
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"vscode": "npm:@codingame/monaco-vscode-api@1.
|
|
22
|
-
"monaco-editor": "0.
|
|
21
|
+
"vscode": "npm:@codingame/monaco-vscode-api@1.85.0-next.1",
|
|
22
|
+
"monaco-editor": "0.45.0"
|
|
23
23
|
}
|
|
24
24
|
}
|
|
@@ -5,7 +5,7 @@ import { or, matchesPrefix, matchesWords, matchesContiguousSubString } from 'mon
|
|
|
5
5
|
import { createSingleCallFunction } from 'monaco-editor/esm/vs/base/common/functional.js';
|
|
6
6
|
import { Disposable } from 'monaco-editor/esm/vs/base/common/lifecycle.js';
|
|
7
7
|
import { LRUCache } from 'monaco-editor/esm/vs/base/common/map.js';
|
|
8
|
-
import {
|
|
8
|
+
import { TfIdfCalculator, normalizeTfIdfScores } from 'vscode/vscode/vs/base/common/tfIdf';
|
|
9
9
|
import { localizeWithPath } from 'monaco-editor/esm/vs/nls.js';
|
|
10
10
|
import { ICommandService } from 'monaco-editor/esm/vs/platform/commands/common/commands.js';
|
|
11
11
|
import { IConfigurationService } from 'monaco-editor/esm/vs/platform/configuration/common/configuration.js';
|
|
@@ -13,7 +13,7 @@ import '../../../../../../override/vs/platform/dialogs/common/dialogs.js';
|
|
|
13
13
|
import { IInstantiationService } from 'monaco-editor/esm/vs/platform/instantiation/common/instantiation.js';
|
|
14
14
|
import { IKeybindingService } from 'monaco-editor/esm/vs/platform/keybinding/common/keybinding.js';
|
|
15
15
|
import { PickerQuickAccessProvider } from 'vscode/vscode/vs/platform/quickinput/browser/pickerQuickAccess';
|
|
16
|
-
import { IStorageService } from 'monaco-editor/esm/vs/platform/storage/common/storage.js';
|
|
16
|
+
import { WillSaveStateReason, IStorageService } from 'monaco-editor/esm/vs/platform/storage/common/storage.js';
|
|
17
17
|
import { ITelemetryService } from 'monaco-editor/esm/vs/platform/telemetry/common/telemetry.js';
|
|
18
18
|
import { IDialogService } from 'vscode/vscode/vs/platform/dialogs/common/dialogs';
|
|
19
19
|
|
|
@@ -43,7 +43,7 @@ let AbstractCommandsQuickAccessProvider = class AbstractCommandsQuickAccessProvi
|
|
|
43
43
|
const tfidf = ( new TfIdfCalculator());
|
|
44
44
|
tfidf.updateDocuments(( allCommandPicks.map(commandPick => ({
|
|
45
45
|
key: commandPick.commandId,
|
|
46
|
-
textChunks: [
|
|
46
|
+
textChunks: [this.getTfIdfChunk(commandPick)]
|
|
47
47
|
}))));
|
|
48
48
|
const result = tfidf.calculateScores(filter, token);
|
|
49
49
|
return normalizeTfIdfScores(result)
|
|
@@ -232,6 +232,16 @@ let AbstractCommandsQuickAccessProvider = class AbstractCommandsQuickAccessProvi
|
|
|
232
232
|
}
|
|
233
233
|
};
|
|
234
234
|
}
|
|
235
|
+
getTfIdfChunk({ label, commandAlias, commandDescription }) {
|
|
236
|
+
let chunk = label;
|
|
237
|
+
if (commandAlias && commandAlias !== label) {
|
|
238
|
+
chunk += ` - ${commandAlias}`;
|
|
239
|
+
}
|
|
240
|
+
if (commandDescription && commandDescription.value !== label) {
|
|
241
|
+
chunk += ` - ${commandDescription.value === commandDescription.original ? commandDescription.value : `${commandDescription.value} (${commandDescription.original})`}`;
|
|
242
|
+
}
|
|
243
|
+
return chunk;
|
|
244
|
+
}
|
|
235
245
|
};
|
|
236
246
|
AbstractCommandsQuickAccessProvider = AbstractCommandsQuickAccessProvider_1 = ( __decorate([
|
|
237
247
|
( __param(1, IInstantiationService)),
|
|
@@ -246,6 +256,7 @@ let CommandsHistory = class CommandsHistory extends Disposable {
|
|
|
246
256
|
static { this.PREF_KEY_CACHE = 'commandPalette.mru.cache'; }
|
|
247
257
|
static { this.PREF_KEY_COUNTER = 'commandPalette.mru.counter'; }
|
|
248
258
|
static { this.counter = 1; }
|
|
259
|
+
static { this.hasChanges = false; }
|
|
249
260
|
constructor(storageService, configurationService) {
|
|
250
261
|
super();
|
|
251
262
|
this.storageService = storageService;
|
|
@@ -257,6 +268,11 @@ let CommandsHistory = class CommandsHistory extends Disposable {
|
|
|
257
268
|
}
|
|
258
269
|
registerListeners() {
|
|
259
270
|
this._register(this.configurationService.onDidChangeConfiguration(e => this.updateConfiguration(e)));
|
|
271
|
+
this._register(this.storageService.onWillSaveState(e => {
|
|
272
|
+
if (e.reason === WillSaveStateReason.SHUTDOWN) {
|
|
273
|
+
this.saveState();
|
|
274
|
+
}
|
|
275
|
+
}));
|
|
260
276
|
}
|
|
261
277
|
updateConfiguration(e) {
|
|
262
278
|
if (e && !e.affectsConfiguration('workbench.commandPalette.history')) {
|
|
@@ -265,7 +281,7 @@ let CommandsHistory = class CommandsHistory extends Disposable {
|
|
|
265
281
|
this.configuredCommandsHistoryLength = CommandsHistory_1.getConfiguredCommandHistoryLength(this.configurationService);
|
|
266
282
|
if (CommandsHistory_1.cache && CommandsHistory_1.cache.limit !== this.configuredCommandsHistoryLength) {
|
|
267
283
|
CommandsHistory_1.cache.limit = this.configuredCommandsHistoryLength;
|
|
268
|
-
CommandsHistory_1.
|
|
284
|
+
CommandsHistory_1.hasChanges = true;
|
|
269
285
|
}
|
|
270
286
|
}
|
|
271
287
|
load() {
|
|
@@ -296,19 +312,23 @@ let CommandsHistory = class CommandsHistory extends Disposable {
|
|
|
296
312
|
return;
|
|
297
313
|
}
|
|
298
314
|
CommandsHistory_1.cache.set(commandId, CommandsHistory_1.counter++);
|
|
299
|
-
CommandsHistory_1.
|
|
315
|
+
CommandsHistory_1.hasChanges = true;
|
|
300
316
|
}
|
|
301
317
|
peek(commandId) {
|
|
302
318
|
return CommandsHistory_1.cache?.peek(commandId);
|
|
303
319
|
}
|
|
304
|
-
|
|
320
|
+
saveState() {
|
|
305
321
|
if (!CommandsHistory_1.cache) {
|
|
306
322
|
return;
|
|
307
323
|
}
|
|
324
|
+
if (!CommandsHistory_1.hasChanges) {
|
|
325
|
+
return;
|
|
326
|
+
}
|
|
308
327
|
const serializedCache = { usesLRU: true, entries: [] };
|
|
309
328
|
CommandsHistory_1.cache.forEach((value, key) => serializedCache.entries.push({ key, value }));
|
|
310
|
-
storageService.store(CommandsHistory_1.PREF_KEY_CACHE, JSON.stringify(serializedCache), 0 , 0 );
|
|
311
|
-
storageService.store(CommandsHistory_1.PREF_KEY_COUNTER, CommandsHistory_1.counter, 0 , 0 );
|
|
329
|
+
this.storageService.store(CommandsHistory_1.PREF_KEY_CACHE, JSON.stringify(serializedCache), 0 , 0 );
|
|
330
|
+
this.storageService.store(CommandsHistory_1.PREF_KEY_COUNTER, CommandsHistory_1.counter, 0 , 0 );
|
|
331
|
+
CommandsHistory_1.hasChanges = false;
|
|
312
332
|
}
|
|
313
333
|
static getConfiguredCommandHistoryLength(configurationService) {
|
|
314
334
|
const config = configurationService.getValue();
|
|
@@ -322,7 +342,7 @@ let CommandsHistory = class CommandsHistory extends Disposable {
|
|
|
322
342
|
const commandHistoryLength = CommandsHistory_1.getConfiguredCommandHistoryLength(configurationService);
|
|
323
343
|
CommandsHistory_1.cache = ( new LRUCache(commandHistoryLength));
|
|
324
344
|
CommandsHistory_1.counter = 1;
|
|
325
|
-
CommandsHistory_1.
|
|
345
|
+
CommandsHistory_1.hasChanges = true;
|
|
326
346
|
}
|
|
327
347
|
};
|
|
328
348
|
CommandsHistory = CommandsHistory_1 = ( __decorate([
|
|
@@ -27,7 +27,8 @@ import { IProductService } from 'monaco-editor/esm/vs/platform/product/common/pr
|
|
|
27
27
|
import { IChatService } from 'vscode/vscode/vs/workbench/contrib/chat/common/chatService';
|
|
28
28
|
import { ASK_QUICK_QUESTION_ACTION_ID } from 'vscode/vscode/vs/workbench/contrib/chat/browser/actions/chatQuickInputActions';
|
|
29
29
|
import { RelatedInformationType, IAiRelatedInformationService } from 'vscode/vscode/vs/workbench/services/aiRelatedInformation/common/aiRelatedInformation';
|
|
30
|
-
import { CHAT_OPEN_ACTION_ID } from '
|
|
30
|
+
import { CHAT_OPEN_ACTION_ID } from 'vscode/vscode/vs/workbench/contrib/chat/browser/actions/chatActions';
|
|
31
|
+
import { isLocalizedString } from 'monaco-editor/esm/vs/platform/action/common/action.js';
|
|
31
32
|
import { IDialogService } from 'vscode/vscode/vs/platform/dialogs/common/dialogs';
|
|
32
33
|
|
|
33
34
|
var CommandsQuickAccessProvider_1;
|
|
@@ -193,10 +194,15 @@ let CommandsQuickAccessProvider = class CommandsQuickAccessProvider extends Abst
|
|
|
193
194
|
const commandAlias = (aliasLabel && category) ?
|
|
194
195
|
aliasCategory ? `${aliasCategory}: ${aliasLabel}` : `${category}: ${aliasLabel}` :
|
|
195
196
|
aliasLabel;
|
|
197
|
+
const metadataDescription = action.item.metadata?.description;
|
|
198
|
+
const commandDescription = metadataDescription === undefined || isLocalizedString(metadataDescription)
|
|
199
|
+
? metadataDescription
|
|
200
|
+
: { value: metadataDescription, original: metadataDescription };
|
|
196
201
|
globalCommandPicks.push({
|
|
197
202
|
commandId: action.item.id,
|
|
198
203
|
commandAlias,
|
|
199
|
-
label: stripIcons(label)
|
|
204
|
+
label: stripIcons(label),
|
|
205
|
+
commandDescription,
|
|
200
206
|
});
|
|
201
207
|
}
|
|
202
208
|
globalCommandsMenu.dispose();
|
|
@@ -78,7 +78,7 @@ let ViewQuickAccessProvider = class ViewQuickAccessProvider extends PickerQuickA
|
|
|
78
78
|
for (const view of viewContainerModel.allViewDescriptors) {
|
|
79
79
|
if (this.contextKeyService.contextMatchesRules(view.when)) {
|
|
80
80
|
result.push({
|
|
81
|
-
label: view.name,
|
|
81
|
+
label: view.name.value,
|
|
82
82
|
containerLabel: viewContainerModel.title,
|
|
83
83
|
accept: () => this.viewsService.openView(view.id, true)
|
|
84
84
|
});
|
|
@@ -54,11 +54,20 @@ class QuickInputHoverDelegate {
|
|
|
54
54
|
this.placement = 'element';
|
|
55
55
|
}
|
|
56
56
|
showHover(options, focus) {
|
|
57
|
+
const showHoverHint = (options.content instanceof HTMLElement
|
|
58
|
+
? options.content.textContent ?? ''
|
|
59
|
+
: typeof options.content === 'string'
|
|
60
|
+
? options.content
|
|
61
|
+
: options.content.value).length > 20;
|
|
57
62
|
return this.hoverService.showHover({
|
|
58
63
|
...options,
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
64
|
+
persistence: {
|
|
65
|
+
hideOnKeyDown: false,
|
|
66
|
+
},
|
|
67
|
+
appearance: {
|
|
68
|
+
showHoverHint,
|
|
69
|
+
skipFadeInAnimation: true,
|
|
70
|
+
},
|
|
62
71
|
}, focus);
|
|
63
72
|
}
|
|
64
73
|
onDidHideHover() {
|
|
@@ -1,138 +0,0 @@
|
|
|
1
|
-
function countMapFrom(values) {
|
|
2
|
-
const map = ( new Map());
|
|
3
|
-
for (const value of values) {
|
|
4
|
-
map.set(value, (map.get(value) ?? 0) + 1);
|
|
5
|
-
}
|
|
6
|
-
return map;
|
|
7
|
-
}
|
|
8
|
-
class TfIdfCalculator {
|
|
9
|
-
constructor() {
|
|
10
|
-
this.chunkCount = 0;
|
|
11
|
-
this.chunkOccurrences = ( new Map());
|
|
12
|
-
this.documents = ( new Map());
|
|
13
|
-
}
|
|
14
|
-
calculateScores(query, token) {
|
|
15
|
-
const embedding = this.computeEmbedding(query);
|
|
16
|
-
const idfCache = ( new Map());
|
|
17
|
-
const scores = [];
|
|
18
|
-
for (const [key, doc] of this.documents) {
|
|
19
|
-
if (token.isCancellationRequested) {
|
|
20
|
-
return [];
|
|
21
|
-
}
|
|
22
|
-
for (const chunk of doc.chunks) {
|
|
23
|
-
const score = this.computeSimilarityScore(chunk, embedding, idfCache);
|
|
24
|
-
if (score > 0) {
|
|
25
|
-
scores.push({ key, score });
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
return scores;
|
|
30
|
-
}
|
|
31
|
-
static termFrequencies(input) {
|
|
32
|
-
return countMapFrom(TfIdfCalculator.splitTerms(input));
|
|
33
|
-
}
|
|
34
|
-
static *splitTerms(input) {
|
|
35
|
-
const normalize = (word) => word.toLowerCase();
|
|
36
|
-
for (const [word] of input.matchAll(/\b\p{Letter}[\p{Letter}\d]{2,}\b/gu)) {
|
|
37
|
-
yield normalize(word);
|
|
38
|
-
const camelParts = word.split(/(?<=[a-z])(?=[A-Z])/g);
|
|
39
|
-
if (camelParts.length > 1) {
|
|
40
|
-
for (const part of camelParts) {
|
|
41
|
-
if (part.length > 2 && /\p{Letter}{3,}/gu.test(part)) {
|
|
42
|
-
yield normalize(part);
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
updateDocuments(documents) {
|
|
49
|
-
for (const { key } of documents) {
|
|
50
|
-
this.deleteDocument(key);
|
|
51
|
-
}
|
|
52
|
-
for (const doc of documents) {
|
|
53
|
-
const chunks = [];
|
|
54
|
-
for (const text of doc.textChunks) {
|
|
55
|
-
const tf = TfIdfCalculator.termFrequencies(text);
|
|
56
|
-
for (const term of ( tf.keys())) {
|
|
57
|
-
this.chunkOccurrences.set(term, (this.chunkOccurrences.get(term) ?? 0) + 1);
|
|
58
|
-
}
|
|
59
|
-
chunks.push({ text, tf });
|
|
60
|
-
}
|
|
61
|
-
this.chunkCount += chunks.length;
|
|
62
|
-
this.documents.set(doc.key, { chunks });
|
|
63
|
-
}
|
|
64
|
-
return this;
|
|
65
|
-
}
|
|
66
|
-
deleteDocument(key) {
|
|
67
|
-
const doc = this.documents.get(key);
|
|
68
|
-
if (!doc) {
|
|
69
|
-
return;
|
|
70
|
-
}
|
|
71
|
-
this.documents.delete(key);
|
|
72
|
-
this.chunkCount -= doc.chunks.length;
|
|
73
|
-
for (const chunk of doc.chunks) {
|
|
74
|
-
for (const term of ( chunk.tf.keys())) {
|
|
75
|
-
const currentOccurrences = this.chunkOccurrences.get(term);
|
|
76
|
-
if (typeof currentOccurrences === 'number') {
|
|
77
|
-
const newOccurrences = currentOccurrences - 1;
|
|
78
|
-
if (newOccurrences <= 0) {
|
|
79
|
-
this.chunkOccurrences.delete(term);
|
|
80
|
-
}
|
|
81
|
-
else {
|
|
82
|
-
this.chunkOccurrences.set(term, newOccurrences);
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
computeSimilarityScore(chunk, queryEmbedding, idfCache) {
|
|
89
|
-
let sum = 0;
|
|
90
|
-
for (const [term, termTfidf] of Object.entries(queryEmbedding)) {
|
|
91
|
-
const chunkTf = chunk.tf.get(term);
|
|
92
|
-
if (!chunkTf) {
|
|
93
|
-
continue;
|
|
94
|
-
}
|
|
95
|
-
let chunkIdf = idfCache.get(term);
|
|
96
|
-
if (typeof chunkIdf !== 'number') {
|
|
97
|
-
chunkIdf = this.computeIdf(term);
|
|
98
|
-
idfCache.set(term, chunkIdf);
|
|
99
|
-
}
|
|
100
|
-
const chunkTfidf = chunkTf * chunkIdf;
|
|
101
|
-
sum += chunkTfidf * termTfidf;
|
|
102
|
-
}
|
|
103
|
-
return sum;
|
|
104
|
-
}
|
|
105
|
-
computeEmbedding(input) {
|
|
106
|
-
const tf = TfIdfCalculator.termFrequencies(input);
|
|
107
|
-
return this.computeTfidf(tf);
|
|
108
|
-
}
|
|
109
|
-
computeIdf(term) {
|
|
110
|
-
const chunkOccurrences = this.chunkOccurrences.get(term) ?? 0;
|
|
111
|
-
return chunkOccurrences > 0
|
|
112
|
-
? Math.log((this.chunkCount + 1) / chunkOccurrences)
|
|
113
|
-
: 0;
|
|
114
|
-
}
|
|
115
|
-
computeTfidf(termFrequencies) {
|
|
116
|
-
const embedding = Object.create(null);
|
|
117
|
-
for (const [word, occurrences] of termFrequencies) {
|
|
118
|
-
const idf = this.computeIdf(word);
|
|
119
|
-
if (idf > 0) {
|
|
120
|
-
embedding[word] = occurrences * idf;
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
return embedding;
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
function normalizeTfIdfScores(scores) {
|
|
127
|
-
const result = scores.slice(0);
|
|
128
|
-
result.sort((a, b) => b.score - a.score);
|
|
129
|
-
const max = result[0]?.score ?? 0;
|
|
130
|
-
if (max > 0) {
|
|
131
|
-
for (const score of result) {
|
|
132
|
-
score.score /= max;
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
return result;
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
export { TfIdfCalculator, normalizeTfIdfScores };
|