Skip to content

Commit 3c9bde7

Browse files
committed
0.24.0 - Added Project snippets section
1 parent 13d0747 commit 3c9bde7

21 files changed

+349
-159
lines changed

.github/ISSUE_TEMPLATE/bug_report.md

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,11 @@ assignees: ''
1111

1212
A clear and concise description of what the bug is.
1313

14-
## To Reproduce
14+
## To Reproduce
1515

1616
Steps to reproduce the behavior:
17-
1. Go to '...'
18-
2. Click on '....'
19-
3. Scroll down to '....'
20-
4. See error
17+
1. Run command '...'
18+
2. Click on '....' etc.
2119

2220
## Expected behavior
2321

@@ -27,11 +25,11 @@ A clear and concise description of what you expected to happen.
2725

2826
If applicable, add screenshots to help explain your problem.
2927

30-
## Version/environment
28+
## Environment information
3129

3230
Please complete the following information:
33-
- On the main menu, go to *Help*, and select *About* from the drop down. Copy the information from the *About* dialog.
34-
- If you are working remotely or using WSL, please state this too.
31+
- On the main menu, go to *Help*, and select *About* from the drop down. Copy the information from the *About* dialog.
32+
- Are you are working remotely or using WSL? Please state this too.
3533

3634
## Additional context
3735

CHANGELOG.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,22 @@ All notable changes to this project are documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
## [0.24.0] - 2023-10-15
9+
10+
### Added
11+
12+
- Added **Project** snippets section. The source of the snippets is from files with the *.code-snippets* extension found in the *.vscode* folder in your workspace.
13+
- Added `scope` field for snippets (*snippets.js*).
14+
- Added GitHub issue template for bugs. This was done on github.com but edited locally.
15+
16+
### Changed
17+
18+
- The `id` attribute generated for `h3` headings is in the form of the *<section-id>-<title>*. Now the `title` portion is slugified. This ensures that there are no unwanted characters that can break links for table of contents.
19+
- The `scope` field is shown in tables when there is at least one instance of the field in the **project**, **user** and **vs code** snippet files.
20+
- Updated animated image demonstrating UI to reflect that project snippets are there now also. I used WebP instead of GIF for better compression/quality.
21+
- Some refactoring to improve readability.
22+
- Updated tests to reflect changes.
23+
824
## [0.23.0] - 2023-10-14
925

1026
### Changed

README.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,16 +22,17 @@ alt="Extension file size in bytes">
2222
</p>
2323

2424
<p align="center">
25-
<img src="img/screenshots/demo.gif" alt="demo"/>
25+
<img src="img/screenshots/demo.webp" width="556" height="482"
26+
alt="recording of exploring view opened from the command 'Snippets Ranger: Show me that dur Range, Partner'. An entry of 'Markdown snippets' from the table of contents is selected and clicked, it takes the user down to the table with the snippets displayed for that extension."/>
2627
</p>
2728

28-
**Snippets are grouped as: *User*, *Extension*, and *VS Code*.**
29+
**Snippets are grouped as: *Project*, *User*, *Extension*, and *VS Code*.**
2930

3031
The table of contents facilitates quick navigation to a snippets set. Pressing the <kbd>Home</kbd> key will return you to the table of contents.
3132

3233
There are sticky headings to ensure you can browse through long snippet lists without losing context. 🦎🔝
3334

34-
You can go to the source snippet file directly with the *View Source File* button. The extension uses **the exact same source files as VS Code**.
35+
You can go to the source snippet file directly with the *View Source File* button. The extension uses **the exact same source files as VS Code does**.
3536

3637
![view source screenshot](img/screenshots/view-source.png)
3738

@@ -71,7 +72,7 @@ You can show your appreciation by:
7172
1. Leaving a positive review in the [visual studio marketplace](https://marketplace.visualstudio.com/items?itemName=robole.snippets-ranger&ssr=false#review-details).
7273
1. Starring the repo 🌟.
7374

74-
This will **help other people find the extension**. It will **offer me encouragement** to continue maintenance, and can provide **a path to dedicating more time to open-source** in the future.
75+
This will **help other people find the extension**. It will **encourage me to continue maintenance**, and may provide **a path to dedicating more time to open-source** in the future.
7576

7677
## Learn more about snippets
7778

img/screenshots/demo.gif

-814 KB
Binary file not shown.

img/screenshots/demo.mp4

723 KB
Binary file not shown.

img/screenshots/demo.webp

852 KB
Loading

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
},
88
"description": "View and edit all your snippets in one purty place. Yee-haw!",
99
"icon": "img/logo.png",
10-
"version": "0.23.0",
10+
"version": "0.24.0",
1111
"engines": {
1212
"vscode": "^1.4.0",
1313
"node": ">=12.0.0"

src/css/styles.css

Lines changed: 70 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
--code-color-light-mode: #7a5600;
1919
--code-color-dark-mode: #d7ba7d;
2020
--table-action-column-width: 80px;
21-
--table-min-width: 600px;
21+
--table-min-width: 800px;
2222
}
2323

2424
*,
@@ -50,9 +50,7 @@ body.vscode-high-contrast {
5050
border-radius: 10px;
5151
}
5252

53-
section#user h2,
54-
section#extension h2,
55-
section#app h2,
53+
section h2,
5654
h3,
5755
h4 {
5856
font-family: var(--vscode-font-family);
@@ -66,9 +64,7 @@ h4 {
6664
min-width: var(--table-min-width);
6765
}
6866

69-
section#user h2,
70-
section#extension h2,
71-
section#app h2 {
67+
section h2 {
7268
top: 0;
7369
z-index: 1000;
7470
text-align: center;
@@ -130,6 +126,26 @@ button {
130126
border-radius: inherit;
131127
}
132128

129+
@media (min-width: 1000px) {
130+
body,
131+
body.vscode-dark,
132+
body.vscode-light,
133+
body.vscode-high-contrast {
134+
width: 90%;
135+
}
136+
137+
#toTopLink {
138+
--size: 30px;
139+
right: 6%;
140+
}
141+
}
142+
143+
@media (min-width: 1600px) {
144+
#toTopLink {
145+
right: calc((100vw - 1592px) / 2);
146+
}
147+
}
148+
133149
table {
134150
table-layout: fixed;
135151
min-width: var(--table-min-width);
@@ -192,6 +208,50 @@ td:nth-child(5) {
192208
width: var(--table-action-column-width);
193209
}
194210

211+
.scoped-table :is(th:nth-child(3), td:nth-child(3)) {
212+
width: 25%;
213+
}
214+
215+
/* using percentage value breaks down here, maybe because of long words */
216+
.scoped-table :is(th:nth-child(5),td:nth-child(5)) {
217+
width: clamp(120px, 13vw ,240px);
218+
}
219+
220+
.scoped-table :is(th:nth-child(6),td:nth-child(6)) {
221+
width: var(--table-action-column-width);
222+
}
223+
224+
@media (min-width: 1000px) {
225+
th:nth-child(1),
226+
td:nth-child(1) {
227+
width: 15%;
228+
}
229+
230+
th:nth-child(2),
231+
td:nth-child(2) {
232+
display: table-cell;
233+
}
234+
235+
th:nth-child(3),
236+
td:nth-child(3) {
237+
width: 25%;
238+
}
239+
240+
th:nth-child(4),
241+
td:nth-child(4) {
242+
width: calc(40% - var(--table-action-column-width));
243+
}
244+
245+
.scoped-table :is(th:nth-child(2), td:nth-child(2)) {
246+
width: 15%;
247+
}
248+
249+
.scoped-table :is(th:nth-child(3), td:nth-child(3)) {
250+
width: 20%;
251+
}
252+
}
253+
254+
195255
body.vscode-dark td,
196256
body.vscode-high-contrast td {
197257
border-bottom: 1px solid var(--table-divider-color-dark-mode);
@@ -235,9 +295,7 @@ body.vscode-light {
235295
color: var(--body-color-light-mode);
236296
}
237297

238-
body.vscode-light section#user h2,
239-
body.vscode-light section#extension h2,
240-
body.vscode-light section#app h2,
298+
body.vscode-light section h2,
241299
body.vscode-light h3,
242300
body.vscode-light h4 {
243301
background-color: var(--body-bg-color-light-mode);
@@ -263,9 +321,7 @@ body.vscode-dark {
263321
color: var(--body-color-dark-mode);
264322
}
265323

266-
body.vscode-dark section#user h2,
267-
body.vscode-dark section#extension h2,
268-
body.vscode-dark section#app h2,
324+
body.vscode-dark section h2,
269325
body.vscode-dark h3,
270326
body.vscode-dark h4 {
271327
background-color: var(--body-bg-color-dark-mode);
@@ -295,9 +351,7 @@ body.vscode-high-contrast {
295351
color: var(--body-color-contrast-mode);
296352
}
297353

298-
body.vscode-high-contrast section#user h2,
299-
body.vscode-high-contrast section#extension h2,
300-
body.vscode-high-contrast section#app h2,
354+
body.vscode-high-contrast section h2,
301355
body.vscode-high-contrast h3,
302356
body.vscode-high-contrast h4 {
303357
background-color: var(--body-bg-color-contrast-mode);
@@ -370,43 +424,3 @@ body.vscode-high-contrast button {
370424
display: block;
371425
margin: 0 auto;
372426
}
373-
374-
@media (min-width: 1000px) {
375-
body,
376-
body.vscode-dark,
377-
body.vscode-light,
378-
body.vscode-high-contrast {
379-
width: 90%;
380-
}
381-
382-
#toTopLink {
383-
--size: 30px;
384-
right: 6%;
385-
}
386-
387-
th:nth-child(1),
388-
td:nth-child(1) {
389-
width: 15%;
390-
}
391-
392-
th:nth-child(2),
393-
td:nth-child(2) {
394-
display: table-cell;
395-
}
396-
397-
th:nth-child(3),
398-
td:nth-child(3) {
399-
width: 25%;
400-
}
401-
402-
th:nth-child(4),
403-
td:nth-child(4) {
404-
width: calc(40% - var(--table-action-column-width));
405-
}
406-
}
407-
408-
@media (min-width: 1600px) {
409-
#toTopLink {
410-
right: calc((100vw - 1592px) / 2);
411-
}
412-
}

src/environment.js

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ const fs = require("fs");
33
// eslint-disable-next-line import/no-unresolved
44
const vscode = require("vscode");
55
const glob = require("glob");
6-
const ExtensionSnippets = require("./extension-snippets");
6+
const ExtensionSnippets = require("./extension-snippets-collection");
77

88
/**
99
* Environment information.
@@ -65,7 +65,7 @@ class Environment {
6565
* Get the filepaths for all of the User Snippets files.
6666
* @returns {Promise} Promise with array of filepaths.
6767
*/
68-
async getUserSnippetsPaths() {
68+
async getUserSnippetFilepaths() {
6969
let list = [];
7070

7171
let filenames = await fs.promises
@@ -88,7 +88,7 @@ class Environment {
8888
* @return {Promise} Promise with array of filepaths.
8989
*/
9090
// eslint-disable-next-line class-methods-use-this
91-
async getAppSnippetsPaths() {
91+
async getAppSnippetFilepaths() {
9292
let extensionRoot = resolve(vscode.env.appRoot, "extensions");
9393
return new Promise((fufil, reject) => {
9494
glob(`${extensionRoot}/**/snippets/*.code-snippets`, {}, (err, files) => {
@@ -101,13 +101,33 @@ class Environment {
101101
});
102102
}
103103

104+
/**
105+
* Get the filepaths for all of the snippets files in the opened project.
106+
* @return {Promise} Promise with array of filepaths.
107+
*/
108+
// eslint-disable-next-line class-methods-use-this
109+
async getProjectSnippetFilepaths() {
110+
let root = vscode.workspace.workspaceFolders[0].uri.fsPath
111+
112+
return new Promise((fufil, reject) => {
113+
glob(`${root}/.vscode/*.code-snippets`, { dot : true}, (err, files) => {
114+
if (err) {
115+
reject(err);
116+
} else {
117+
fufil(files);
118+
}
119+
});
120+
});
121+
}
122+
104123
/**
105124
* Get the filepaths for all of Extension Snippets file.
106125
* @return {Promise} Promise with array of filepaths.
107126
*/
108127
// eslint-disable-next-line class-methods-use-this
109128
async getExtensionSnippets() {
110129
let array = [];
130+
111131
vscode.extensions.all.forEach((extension) => {
112132
let { packageJSON } = extension;
113133
if (
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* Snippets for a particular extension. An Extension can have snippets declared in
33
* different files. One snippet file can be associated with 1 or more languages.
44
*/
5-
class ExtensionSnippets {
5+
class ExtensionSnippetsCollection {
66
constructor(name, displayName, publisher) {
77
this.name = name;
88
this.displayName = displayName;
@@ -33,4 +33,4 @@ class ExtensionSnippets {
3333
}
3434
}
3535

36-
module.exports = ExtensionSnippets;
36+
module.exports = ExtensionSnippetsCollection;

0 commit comments

Comments
 (0)