-
Notifications
You must be signed in to change notification settings - Fork 293
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
195 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,3 +3,4 @@ node_modules | |
_jest-editor/ | ||
integrations/create-react-example/node_modules | ||
/coverage/ | ||
/.vscode/symbols.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
import * as vscode from 'vscode' | ||
import { extensionName } from './appGlobals' | ||
import { basename } from 'path' | ||
import { DecorationOptions } from './types' | ||
|
||
class CodeLens extends vscode.CodeLens { | ||
readonly identifier: string | ||
readonly fileName: string | ||
constructor(range: vscode.Range, fileName: string, identifier: string) { | ||
super(range) | ||
this.fileName = fileName | ||
this.identifier = identifier | ||
} | ||
} | ||
|
||
export class CodeLensProvider implements vscode.CodeLensProvider { | ||
private didChangeCodeLenses: vscode.EventEmitter<void> | ||
private decorations: DecorationOptions[] | ||
|
||
constructor() { | ||
this.didChangeCodeLenses = new vscode.EventEmitter() | ||
} | ||
|
||
get onDidChangeCodeLenses(): vscode.Event<void> { | ||
return this.didChangeCodeLenses.event | ||
} | ||
|
||
provideCodeLenses( | ||
document: vscode.TextDocument, | ||
_token: vscode.CancellationToken | ||
): vscode.ProviderResult<vscode.CodeLens[]> { | ||
return (this.decorations || []).map(o => { | ||
const range = new vscode.Range( | ||
o.range.start.line, | ||
o.range.start.character, | ||
o.range.start.line, | ||
o.range.start.character + 5 // lenses all have text 'Debug' | ||
) | ||
return new CodeLens(range, basename(document.fileName), o.identifier) | ||
}) | ||
} | ||
|
||
resolveCodeLens(codeLens: vscode.CodeLens, _token: vscode.CancellationToken): vscode.ProviderResult<vscode.CodeLens> { | ||
if (codeLens instanceof CodeLens) { | ||
codeLens.command = { | ||
arguments: [codeLens.fileName, codeLens.identifier], | ||
command: `${extensionName}.run-test`, | ||
title: 'Debug', | ||
} | ||
} | ||
return codeLens | ||
} | ||
|
||
updateLenses(decorations: DecorationOptions[]) { | ||
this.decorations = decorations | ||
this.didChangeCodeLenses.fire() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import * as vscode from 'vscode' | ||
|
||
export interface DecorationOptions extends vscode.DecorationOptions { | ||
identifier: string | ||
} |
Do you think we could make this work with non-standard values like when folks have set the
"jest.pathToJest"
by running mimicking hownpm run
works? As I understand it, thenode_modules/.bin
directory is added to thePATH
and it's launched withnode
. If we got the position inPATH
right, that'd cover non-standard global and local node modules as well as plain oldjest
.This comes up in #193.