Skip to content

Commit

Permalink
Tests / fixes for moveBy (#52)
Browse files Browse the repository at this point in the history
Adds tests to verify working unit motions, and simplifies and corrects
the unit-motion logic.
  • Loading branch information
haberdashPI authored Sep 19, 2024
1 parent 386a933 commit 5eb4026
Show file tree
Hide file tree
Showing 18 changed files with 950 additions and 186 deletions.
3 changes: 2 additions & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@
{
"allowModules": [
"lodash",
"wdio-vscode-service"
"wdio-vscode-service",
"string.prototype.replaceall"
]
}
],
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ dist/*
.DS_Store
.cache/
.parcel-cache
wdio.conf.mts
.wdio-vscode-service
wdio.log
coverage/**
.package.json
1 change: 1 addition & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
"debugWebWorkerHost": true,
"request": "launch",
"args": [
"--profile=debug-profile",
"--extensionDevelopmentPath=${workspaceFolder}",
"--extensionDevelopmentKind=web"
],
Expand Down
4 changes: 2 additions & 2 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
{
"label": "npm: compile-web",
"type": "shell",
"command": "bash ./npm-run.sh compile",
"command": "bash ./npm-run.sh compile-web",
"group": {
"kind": "build",
"isDefault": true
Expand All @@ -19,7 +19,7 @@
{
"label": "npm: watch-web",
"type": "shell",
"command": "bash ./npm-run.sh watch",
"command": "bash ./npm-run.sh watch-web",
"group": "build",
"isBackground": true,
"problemMatcher": [
Expand Down
3 changes: 3 additions & 0 deletions debug-profile.code-profile
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"name": "debug-profile"
}
4 changes: 4 additions & 0 deletions notes.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Currently debugging issue with `resolveUnit` in `unitMotions`

problem: when using start or end boundaries (instead of both), the selectWhole
skips every even unit
5 changes: 3 additions & 2 deletions npm-run.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#!/bin/bash
export NVM_DIR="$([ -z "${XDG_CONFIG_HOME-}" ] && printf %s "${HOME}/.nvm" || printf %s "${XDG_CONFIG_HOME}/nvm")"
NVM_DIR="$([ -z "${XDG_CONFIG_HOME-}" ] && printf %s "${HOME}/.nvm" || printf %s "${XDG_CONFIG_HOME}/nvm")"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # load nvm
nvm install
nvm use
npm run $@
npm run "$@"
27 changes: 25 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 6 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"publisher": "haberdashPI",
"repository": "https://github.com/haberdashPI/vscode-selection-utilities",
"description": "Kakaune-inspired collection of useful commands for manipulating selections.",
"version": "0.6.6",
"version": "0.6.7",
"icon": "logo.png",
"engines": {
"vscode": "^1.92.0"
Expand Down Expand Up @@ -46,6 +46,10 @@
"name": "word",
"regex": "(_*[\\p{L}][_\\p{L}0-9]*)|(_+)|([0-9][0-9.]*)|((?<=[\\s\\r\\n])[^\\p{L}^\\s]+(?=[\\s\\r\\n]))"
},
{
"name": "number",
"regex": "[0-9]+"
},
{
"name": "subword",
"regex": "(_*[\\p{L}][0-9\\p{Ll}]+_*)|(_+)|(\\p{Lu}[\\p{Lu}0-9]+_*(?!\\p{Ll}))|(\\p{L})|([^\\p{L}^\\s^0-9])|([0-9][0-9.]*)"
Expand Down Expand Up @@ -450,6 +454,7 @@
"nyc": "^17.0.0",
"penv": "^0.2.0",
"process": "^0.11.10",
"string.prototype.replaceall": "^1.0.10",
"ts-loader": "^9.5.1",
"typescript": "^5.4.3",
"wdio-vscode-service": "^6.0.3",
Expand Down
7 changes: 5 additions & 2 deletions src/web/activeMotions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,9 @@ function revealActive(args: {at: 'top' | 'center' | 'bottom'} = {at: 'center'})
}
}

function activePageMove(args: {dir?: 'up' | 'down'; count?: number, select?: boolean} = {}) {
function activePageMove(
args: {dir?: 'up' | 'down'; count?: number; select?: boolean} = {}
) {
const editor = vscode.window.activeTextEditor;
if (editor) {
const heights = editor.visibleRanges.map(range => {
Expand All @@ -69,7 +71,8 @@ function activePageMove(args: {dir?: 'up' | 'down'; count?: number, select?: boo
editor.selections = editor.selections.map(sel => {
const active = clampedLineTranslate(sel.active, ed.document, steps);
let anchor = sel.anchor;
if (args.select === false) { // args.select === undefined defaults to true
if (args.select === false) {
// args.select === undefined defaults to true
anchor = active;
}
return new vscode.Selection(anchor, active);
Expand Down
Loading

0 comments on commit 5eb4026

Please sign in to comment.