Skip to content

Commit

Permalink
new commands, a bit of build cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
haberdashPI committed Dec 8, 2023
1 parent adfdfd8 commit 748e4a5
Show file tree
Hide file tree
Showing 4 changed files with 86 additions and 4 deletions.
1 change: 1 addition & 0 deletions .nvmrc
@@ -0,0 +1 @@
v12.22.11
27 changes: 25 additions & 2 deletions .vscode/settings.json
Expand Up @@ -7,5 +7,28 @@
"out": true // set this to false to include "out" folder in search results
},
// Turn off tsc task auto detection since we have the necessary tasks as npm scripts
"typescript.tsc.autoDetect": "off"
}
"typescript.tsc.autoDetect": "off",
"workbench.colorCustomizations": {
"editorBracketHighlight.foreground1": "#1b9e77",
"editorBracketHighlight.foreground2": "#d95f02",
"editorBracketHighlight.foreground3": "#7570b3",
"editorBracketHighlight.foreground4": "#e7298a",
"editorBracketHighlight.foreground5": "#66a61e",
"editorBracketHighlight.foreground6": "#e6ab02",
"editorBracketHighlight.unexpectedBracket.foreground": "#ff0000",
"titleBar.activeBackground": "#768aed",
"titleBar.activeForeground": "#FFFFFF",
"titleBar.inactiveBackground": "#768aed",
"titleBar.inactiveForeground": "#FFFFFF",
"titleBar.border": "#768aed",
"activityBar.background": "#768aed",
"activityBar.foreground": "#FFFFFF",
"statusBar.background": "#768aed",
"statusBar.foreground": "#FFFFFF",
"statusBar.debuggingBackground": "#768aed",
"statusBar.debuggingForeground": "#FFFFFF",
"tab.activeBorder": "#768aed",
"iLoveWorkSpaceColors": true,
"iLoveWorkSpaceRandom": false
}
}
18 changes: 18 additions & 0 deletions package.json
Expand Up @@ -18,6 +18,9 @@
"onCommand:selection-utilities.activeAtStart",
"onCommand:selection-utilities.movePrimaryLeft",
"onCommand:selection-utilities.movePrimaryRight",
"onCommand:selection-utilities.shrinkToActive",
"onCommand:selection-utilities.expandWithinBrackets",
"onCommand:selection-utilities.expandAroundBrackets",
"onCommand:selection-utilities.focusPrimarySelection",
"onCommand:selection-utilities.appendToMemory",
"onCommand:selection-utilities.restoreAndClear",
Expand Down Expand Up @@ -169,6 +172,21 @@
"title": "Exchange active and anchor",
"category": "Selection Utilities"
},
{
"command": "selection-utilities.shrinkToActive",
"title": "Shrink selection to active",
"category": "Selection Utilities"
},
{
"command": "selection-utilities.expandWithinBrackets",
"title": "Expand selection to be within next surrounding brackets",
"category": "Selection Utilities"
},
{
"command": "selection-utilities.expandAroundBrackets",
"title": "Expand selection to be around next surrounding brackets",
"category": "Selection Utilities"
},
{
"command": "selection-utilities.activeAtEnd",
"title": "Active to end",
Expand Down
44 changes: 42 additions & 2 deletions src/symmetricModifiers.ts
@@ -1,13 +1,17 @@
import * as vscode from 'vscode';
import { wrappedTranslate } from './util'

export function registerSymmetricModifiers(context: vscode.ExtensionContext){
export function registerSymmetricModifiers(context: vscode.ExtensionContext) {
context.subscriptions.push(vscode.commands.
registerCommand('selection-utilities.insertAround', insertAround));
context.subscriptions.push(vscode.commands.
registerCommand('selection-utilities.deleteAround', deleteAround));
context.subscriptions.push(vscode.commands.
registerCommand('selection-utilities.adjustSelections', adjustSelections));
context.subscriptions.push(vscode.commands.
registerCommand('selection-utilities.expandWithinBrackets', expandWithinBrackets));
context.subscriptions.push(vscode.commands.
registerCommand('selection-utilities.expandAroundBrackets', expandAroundBrackets));
}

interface InsertAroundArgs{
Expand Down Expand Up @@ -78,4 +82,40 @@ function adjustSelections(args: {dir: string, count: number}){
);
});
}
}
}

function expandWithinBrackets(){
let editor = vscode.window.activeTextEditor;
if(editor){
let ed = editor;
editor.selections = editor.selections.map(sel => {
if(!sel.isEmpty){
return new vscode.Selection(
wrappedTranslate(sel.start, ed.document, -2),
wrappedTranslate(sel.end, ed.document, 2),
);
}else{
return sel
}
})
vscode.commands.executeCommand('editor.action.selectToBracket', {"selectBrackets": false})
}
}

function expandAroundBrackets(){
let editor = vscode.window.activeTextEditor;
if(editor){
let ed = editor;
editor.selections = editor.selections.map(sel => {
if(!sel.isEmpty){
return new vscode.Selection(
wrappedTranslate(sel.start, ed.document, -1),
wrappedTranslate(sel.end, ed.document, 1),
);
}else{
return sel
}
})
vscode.commands.executeCommand('editor.action.selectToBracket', {"selectBrackets": true})
}
}

0 comments on commit 748e4a5

Please sign in to comment.