Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
* a Create Folder button when a storage location is set but its folder doesn't exist
* move notes and folders by dragging them onto a folder, onto empty space for the top level, or between Workspace Notes and Notes, or with `Move To...` in the right-click menu; open notes stay open at their new location, and several selected items move together
* drag a note onto the editor area to open it
* search inside your notes with VS Code's search: `Notes: Search Notes` covers Workspace Notes and Notes, the search button of each section covers that section, and `Search in Folder` in the right-click menu of a folder covers that folder, even when the notes are outside the workspace (#17)
* notes and folders use the icons of your file icon theme
* a new note keeps an extension typed with its name, like `query.sql` or `data.json`, when VS Code knows a language for it (or it is in `notes.notesExtensions`), otherwise it gets the default extension (#81)

Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ The extension can be accessed using the Notes icon that is placed in the Activit

* quickly create new notes by using the `Alt+N` shortcut, or by click on the `+` icon at the top when you are in Notes.
* quickly access your list of notes by using the `Alt+L` shortcut to bring up a searchable list at the top of VSCode.
* search inside your notes with **Notes: Search Notes**, the search button at the top of each section, or **Search in Folder** in the right-click menu of a folder. It opens VS Code's Search view limited to your notes, wherever they are stored.
* hovering over a note inside Notes displays two icons, one allows you to rename a note and the other allows you to delete a note. *Deleting a note is permanent, so be careful.*
* move notes and folders by dragging them onto a folder (or onto empty space for the top level), between Workspace Notes and Notes, or with **Move To...** in the right-click menu. Select several with `Cmd`/`Ctrl` to move them together, and drag a note onto the editor to open it.

Expand Down
56 changes: 53 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,29 @@
"category": "Notes",
"icon": "$(new-folder)"
},
{
"command": "Notes.searchNotes",
"title": "Search Notes",
"category": "Notes",
"icon": "$(search)"
},
{
"command": "Notes.searchInNotes",
"title": "Search Notes",
"category": "Notes",
"icon": "$(search)"
},
{
"command": "Notes.searchInWorkspaceNotes",
"title": "Search Workspace Notes",
"category": "Notes",
"icon": "$(search)"
},
{
"command": "Notes.searchInFolder",
"title": "Search in Folder",
"category": "Notes"
},
{
"command": "Notes.refreshNotes",
"title": "Refresh Notes",
Expand Down Expand Up @@ -222,10 +245,15 @@
"group": "navigation@2"
},
{
"command": "Notes.refreshNotes",
"command": "Notes.searchInWorkspaceNotes",
"when": "view == workspaceNotes",
"group": "navigation@3"
},
{
"command": "Notes.refreshNotes",
"when": "view == workspaceNotes",
"group": "navigation@4"
},
{
"command": "Notes.revealWorkspaceNotesInOS",
"when": "view == workspaceNotes && (!remoteName || remoteName == wsl)",
Expand All @@ -247,15 +275,20 @@
"group": "navigation@2"
},
{
"command": "Notes.refreshNotes",
"command": "Notes.searchInNotes",
"when": "view == notes",
"group": "navigation@3"
},
{
"command": "Notes.setupNotes",
"command": "Notes.refreshNotes",
"when": "view == notes",
"group": "navigation@4"
},
{
"command": "Notes.setupNotes",
"when": "view == notes",
"group": "navigation@5"
},
{
"command": "Notes.revealInOS",
"when": "view == notes && (!remoteName || remoteName == wsl)",
Expand Down Expand Up @@ -308,6 +341,11 @@
"when": "view =~ /^(notes|workspaceNotes)$/ && viewItem == folder",
"group": "2_workspace@2"
},
{
"command": "Notes.searchInFolder",
"when": "view =~ /^(notes|workspaceNotes)$/ && viewItem == folder",
"group": "4_search@1"
},
{
"command": "Notes.newNoteInNotes",
"when": "view == notes && !viewItem",
Expand Down Expand Up @@ -393,6 +431,18 @@
{
"command": "Notes.move",
"when": "false"
},
{
"command": "Notes.searchInNotes",
"when": "false"
},
{
"command": "Notes.searchInWorkspaceNotes",
"when": "false"
},
{
"command": "Notes.searchInFolder",
"when": "false"
}
]
},
Expand Down
50 changes: 50 additions & 0 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,27 @@ export function activate(context: vscode.ExtensionContext) {
});
context.subscriptions.push(createWorkspaceNotesFolderDisposable);

// search the notes with VS Code's search: every section, one section, or one folder
let searchNotesDisposable = vscode.commands.registerCommand('Notes.searchNotes', () => {
Notes.searchNotes();
});
context.subscriptions.push(searchNotesDisposable);

let searchInNotesDisposable = vscode.commands.registerCommand('Notes.searchInNotes', () => {
Notes.searchNotes('notes');
});
context.subscriptions.push(searchInNotesDisposable);

let searchInWorkspaceNotesDisposable = vscode.commands.registerCommand('Notes.searchInWorkspaceNotes', () => {
Notes.searchNotes('workspace');
});
context.subscriptions.push(searchInWorkspaceNotesDisposable);

let searchInFolderDisposable = vscode.commands.registerCommand('Notes.searchInFolder', (folder?: Note) => {
Notes.searchNotes(undefined, folder);
});
context.subscriptions.push(searchInFolderDisposable);

// reveal in the file explorer of the operating system
let revealInOSDisposable = vscode.commands.registerCommand('Notes.revealInOS', (item?: Note) => {
Notes.revealInOS(item, 'notes');
Expand Down Expand Up @@ -713,6 +734,35 @@ export class Notes {
});
}

// open VS Code's search limited to notes: a folder, one section, or Workspace Notes and Notes together
// VS Code searches folders named this way even outside the workspace or when they are in .gitignore
static searchNotes(kind?: NotesKind, folder?: Note): void {
let folders: string[];
if (folder instanceof Note && folder.isFolder) {
folders = [folder.fullPath];
}
else if (kind) {
const location = Notes.requireLocation(kind);
folders = location ? [location] : [];
}
else {
const kinds: NotesKind[] = Notes.isWorkspaceNotesAvailable() ? ['workspace', 'notes'] : ['notes'];
folders = kinds.map(Notes.getLocation).filter(location => getLocationState(location) === 'ready');
if (!folders.length) {
Notes.requireLocation('notes');
}
}
if (!folders.length) {
return;
}

vscode.commands.executeCommand('workbench.action.findInFiles', {
filesToInclude: folders.join(', '),
showIncludesExcludes: true,
triggerSearch: true
});
}

// move notes and folders into a folder, through VS Code so open editors follow them
static async moveItems(items: readonly MovableItem[], targetFolder: string, tree: Refreshable): Promise<void> {
// a note inside a folder that moves too goes along with it
Expand Down
Loading