Skip to content

Commit fa3daa6

Browse files
committed
Merge branch dev into published
2 parents 335af4e + 1b052df commit fa3daa6

File tree

5 files changed

+27
-21
lines changed

5 files changed

+27
-21
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ Changes to Calva.
44

55
## [Unreleased]
66

7+
## [2.0.477] - 2024-09-29
8+
9+
- Fix: [Global custom repl command keys override workspace dittos, should be the other way around](https://github.com/BetterThanTomorrow/calva/issues/2640)
10+
711
## [2.0.476] - 2024-09-28
812

913
- Fix: [Formatting and some pretty printing croaks on new Clojure 1.12.0 syntax](https://github.com/BetterThanTomorrow/calva/issues/2637)

docs/site/custom-commands.md

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ There are also substitutions available, which will take elements from the curren
4444

4545
## User and Workspace Settings
4646

47-
Settings from your User (global) level and the workspace are merged.
47+
Settings from your User (global) level and the workspace are concatenated. Except for the `key` field, are merged.
4848

4949
With these **User** settings:
5050

@@ -89,9 +89,7 @@ And these **Workspace** settings:
8989

9090
```
9191

92-
Issuing **Run Custom REPL Command** will then render this VS Code menu:
93-
94-
![](images/custom-command-menu.png)
92+
Issuing **Run Custom REPL Command** will then render a VS Code menu with all the commands, where the Workspace configured commands will be listed first.
9593

9694
The default keyboard shortcut for the command is `ctrl+alt+space space`. (Beware: on MacOS it may conflict with the default shortuct for Input Sources - Select next source in Input menu.)
9795

@@ -103,7 +101,7 @@ There are four ways to bind shortcuts to custom commands:
103101
* The digits `0` through `9`
104102
* The English letters `a` through `z`
105103
* Arrow keys `right`, `left`, `up`, or `down`
106-
* One of `tab`, `backspace`, `,`, `.`, or `-`
104+
* One of `tab`, `backspace`, `,`, `.`, or `-`
107105
2. Bind `calva.runCustomREPLCommand` to a shortcut with whatever code you want to evaluate in the `args` slot. You have access to the substitution variables here as well.
108106
3. Bind `calva.runCustomREPLCommand` to a keyboard shortcut referencing the `key` of one of your `calva.customREPLCommandSnippets`. (If not using any of the `key`s mentioned in **1.**)
109107
4. Bind `calva.runCustomREPLCommand` to a shortcut with a `customREPLCommandSnippets` in the `args` slot. You have access to the substitution variables here as well.

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"displayName": "Calva: Clojure & ClojureScript Interactive Programming",
44
"description": "Integrated REPL, formatter, Paredit, and more. Powered by cider-nrepl and clojure-lsp.",
55
"icon": "assets/calva.png",
6-
"version": "2.0.476",
6+
"version": "2.0.477",
77
"publisher": "betterthantomorrow",
88
"author": {
99
"name": "Better Than Tomorrow",

src/custom-snippets.ts

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -87,16 +87,15 @@ async function getSnippetDefinition(codeOrKey: string, editorNS: string, editorR
8787
const workspaceSnippets = getConfig().customREPLCommandSnippetsWorkspace;
8888
const workspaceFolderSnippets = getConfig().customREPLCommandSnippetsWorkspaceFolder;
8989
let snippets = [
90-
...(globalSnippets ? globalSnippets : []),
91-
...(workspaceSnippets ? workspaceSnippets : []),
9290
...(workspaceFolderSnippets ? workspaceFolderSnippets : []),
91+
...(workspaceSnippets ? workspaceSnippets : []),
92+
...(globalSnippets ? globalSnippets : []),
9393
];
9494
if (snippets.length < 1) {
9595
snippets = getConfig().customREPLCommandSnippets;
9696
}
9797
const snippetsDict = {};
98-
const snippetsKeyDict = {};
99-
const snippetsMenuItems: string[] = [];
98+
const snippetsMenuItems: vscode.QuickPickItem[] = [];
10099
snippets.forEach((c: CustomREPLCommandSnippet) => {
101100
const undefs = ['name', 'snippet'].filter((k) => {
102101
return !c[k];
@@ -107,11 +106,16 @@ async function getSnippetDefinition(codeOrKey: string, editorNS: string, editorR
107106
const entry = { ...c };
108107
entry.ns = entry.ns ? entry.ns : editorNS;
109108
entry.repl = entry.repl ? entry.repl : editorRepl;
110-
const prefix = entry.key !== undefined ? `${entry.key}: ` : '';
111-
const item = `${prefix}${entry.name} (${entry.repl})`;
109+
const item = {
110+
label: `${entry.key ? entry.key + ': ' : ''}${entry.name}`,
111+
detail: `${entry.snippet}`,
112+
description: `${entry.repl}`,
113+
snippet: entry.snippet,
114+
};
112115
snippetsMenuItems.push(item);
113-
snippetsDict[item] = entry;
114-
snippetsKeyDict[entry.key] = item;
116+
if (!snippetsDict[entry.key]) {
117+
snippetsDict[entry.key] = entry;
118+
}
115119
});
116120

117121
if (configErrors.length > 0) {
@@ -123,20 +127,20 @@ async function getSnippetDefinition(codeOrKey: string, editorNS: string, editorR
123127
return;
124128
}
125129

126-
let pick: string;
130+
let pick: any;
127131
if (codeOrKey === undefined) {
128132
// Called without args, show snippets menu
129133
if (snippetsMenuItems.length > 0) {
130134
try {
131135
const pickResult = await util.quickPickSingle({
132-
values: snippetsMenuItems.map((a) => ({ label: a })),
136+
values: snippetsMenuItems,
133137
placeHolder: 'Choose a command to run at the REPL',
134138
saveAs: 'runCustomREPLCommand',
135139
});
136140
if (pickResult === undefined || pickResult.label.length < 1) {
137141
return;
138142
}
139-
pick = pickResult.label; // Assign the label property to pick
143+
pick = pickResult;
140144
} catch (e) {
141145
console.error(e);
142146
}
@@ -151,10 +155,10 @@ async function getSnippetDefinition(codeOrKey: string, editorNS: string, editorR
151155

152156
if (pick === undefined) {
153157
// still no pick, but codeOrKey might be one
154-
pick = snippetsKeyDict[codeOrKey];
158+
pick = snippetsDict[codeOrKey];
155159
}
156160

157-
return pick !== undefined ? snippetsDict[pick] : { snippet: codeOrKey };
161+
return pick ?? { snippet: codeOrKey };
158162
}
159163

160164
export function makeContext(editor: vscode.TextEditor, ns: string, editorNS: string, repl: string) {

0 commit comments

Comments
 (0)