Skip to content
Open
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
29 changes: 21 additions & 8 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,24 +8,37 @@

// A task runner that calls a custom npm script that compiles the extension.
{
"version": "0.1.0",
"version": "2.0.0",

// we want to run npm
"command": "npm",

// the command is a shell script
"isShellCommand": true,

// show the output window only if unrecognized errors occur.
"showOutput": "silent",

// we run the custom script "compile" as defined in package.json
"args": ["run", "compile", "--loglevel", "silent"],

// The tsc compiler is started in watching mode
"isBackground": true,

// use the standard tsc in watch mode problem matcher to find compile problems in the output.
"problemMatcher": "$tsc-watch"
"problemMatcher": "$tsc-watch",
"tasks": [
{
"label": "npm",
"type": "shell",
"command": "npm",
"args": [
"run",
"compile",
"--loglevel",
"silent"
],
"isBackground": true,
"problemMatcher": "$tsc-watch",
"group": {
"_id": "build",
"isDefault": false
}
}
]

}
31 changes: 31 additions & 0 deletions .vscode/tasks.json.old
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
// Available variables which can be used inside of strings.
// ${workspaceRoot}: the root folder of the team
// ${file}: the current opened file
// ${fileBasename}: the current opened file's basename
// ${fileDirname}: the current opened file's dirname
// ${fileExtname}: the current opened file's extension
// ${cwd}: the current working directory of the spawned process

// A task runner that calls a custom npm script that compiles the extension.
{
"version": "0.1.0",

// we want to run npm
"command": "npm",

// the command is a shell script
"isShellCommand": true,

// show the output window only if unrecognized errors occur.
"showOutput": "silent",

// we run the custom script "compile" as defined in package.json
"args": ["run", "compile", "--loglevel", "silent"],

// The tsc compiler is started in watching mode
"isBackground": true,

// use the standard tsc in watch mode problem matcher to find compile problems in the output.
"problemMatcher": "$tsc-watch"

}
20 changes: 19 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,24 @@
"description": "Run VSCode 'Format Document' after every log command.",
"default": false
},
"wrap-console-log.languageSkipWordSeparator": {
"type": "object",
"description": "Define language word separators to skip. E.g. for Javascript add '.' to automatically detect full variable references e.g. `object.var`",
"default": {
"javascript": [
"."
],
"typescript": [
"."
],
"javascriptreact": [
"."
],
"typescriptreact": [
"."
]
}
},
"wrap-console-log.configuration.emptyLineAction": {
"type": "string",
"enum": [
Expand Down Expand Up @@ -233,6 +251,6 @@
"devDependencies": {
"@types/node": "^8.10.25",
"typescript": "^3.1.4",
"vscode": "^1.1.34"
"vscode": "^1.1.37"
}
}
23 changes: 22 additions & 1 deletion src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,22 @@ function handle(target: Wrap, prefix?: boolean, input?: boolean, formatAs?: Form
let doc = currentEditor.document;
let lineNumber = ran.start.line
let idx = doc.lineAt(lineNumber).firstNonWhitespaceCharacterIndex
const languageVarSeparators = getSetting("languageSkipWordSeparator")[doc.languageId];

let item = doc.getText(ran)

let wordPrefixChar = getWordPrefixChar(ran);

while (languageVarSeparators?.includes(wordPrefixChar)) {
const prefixWordRan = currentEditor.document.getWordRangeAtPosition(ran.start.translate(0, -2))
ran = new vscode.Range(prefixWordRan.start, ran.end)
item = doc.getText(ran)
wordPrefixChar = getWordPrefixChar(ran);
}

let wrapData = {
txt: undefined,
item: doc.getText(ran),
item: item,
doc: doc,
ran: ran,
idx: idx,
Expand Down Expand Up @@ -283,6 +296,14 @@ function handle(target: Wrap, prefix?: boolean, input?: boolean, formatAs?: Form

}

/** Get character just before range. Returns undefined for empty and start of line. */
function getWordPrefixChar (ran: vscode.Range) {
if (ran.start.character == 0) return undefined;
const charRange = new vscode.Range(ran.start.translate(0, -1), ran.start);
const wordPrefix = currentEditor.document.getText(charRange);
return wordPrefix === ' ' ? undefined : wordPrefix;
};

function getSetting(setting: string) {
var spl = setting.split('.');

Expand Down
Loading