Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix step into local dep with debugger #894

Merged
merged 4 commits into from
Dec 27, 2020
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 @@ -3,6 +3,7 @@
Changes to Calva.

## [Unreleased]
- [Fix step into local dep with debugger](https://github.com/BetterThanTomorrow/calva/issues/893)

## [2.0.137 - 2020-12-24]
- [Bring in clojure-lsp](https://github.com/BetterThanTomorrow/calva/pull/572)
Expand Down
7 changes: 3 additions & 4 deletions src/debugger/calva-debug.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import annotations from '../providers/annotations';
import { NReplSession } from '../nrepl';
import debugDecorations from './decorations';
import * as namespace from '../namespace';
import { removeFileSchemeFromUri } from '../util/string';

const CALVA_DEBUG_CONFIGURATION: DebugConfiguration = {
type: 'clojure',
Expand Down Expand Up @@ -177,8 +176,7 @@ class CalvaDebugSession extends LoggingDebugSession {
protected async stackTraceRequest(response: DebugProtocol.StackTraceResponse, args: DebugProtocol.StackTraceArguments, request?: DebugProtocol.Request): Promise<void> {

const debugResponse = state.deref().get(DEBUG_RESPONSE_KEY);
const filePath = removeFileSchemeFromUri(debugResponse.file);
const document = await vscode.workspace.openTextDocument(filePath);
const document = await vscode.workspace.openTextDocument(vscode.Uri.parse(debugResponse.file));
const positionLine = convertOneBasedToZeroBased(debugResponse.line);
const positionColumn = convertOneBasedToZeroBased(debugResponse.column);
const offset = document.offsetAt(new Position(positionLine, positionColumn));
Expand All @@ -196,7 +194,8 @@ class CalvaDebugSession extends LoggingDebugSession {

const [line, column] = tokenCursor.rowCol;

const source = new Source(basename(filePath), filePath);
// Pass scheme in path argument to Source contructor so that if it's a jar file it's handled correctly
const source = new Source(basename(debugResponse.file), debugResponse.file);
const name = tokenCursor.getFunction();
const stackFrames = [new StackFrame(0, name, source, line + 1, column + 1)];

Expand Down
12 changes: 1 addition & 11 deletions src/extension-test/unit/util/string-test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import * as expect from 'expect';
import { keywordize, unKeywordize, getIndexAfterLastNonWhitespace, getTextAfterLastOccurrenceOfSubstring,
removeFileSchemeFromUri } from '../../../util/string';
import { keywordize, unKeywordize, getIndexAfterLastNonWhitespace, getTextAfterLastOccurrenceOfSubstring } from '../../../util/string';


describe('string', () => {
Expand Down Expand Up @@ -48,13 +47,4 @@ describe('string', () => {
expect('\n\t foo \n\t').toBe(getTextAfterLastOccurrenceOfSubstring('hello > world >\n\t foo \n\t', '>'));
});
});

describe('removeFileSchemeFromUri', () => {
it('removes "file:" from the beginning of a uri', () => {
expect(removeFileSchemeFromUri('file:/some/path')).toBe('/some/path');
});
it ('returns same uri if it does not start with "file:"', () => {
expect(removeFileSchemeFromUri('/some/path')).toBe('/some/path');
});
});
});
6 changes: 3 additions & 3 deletions src/testRunner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import { disabledPrettyPrinter } from './printer';
import * as outputWindow from './results-output/results-doc';
import { NReplSession } from './nrepl';
import * as namespace from './namespace';
import { removeFileSchemeFromUri } from './util/string';

let diagnosticCollection = vscode.languages.createDiagnosticCollection('calva');

Expand Down Expand Up @@ -121,9 +120,10 @@ function runAllTestsCommand() {
async function considerTestNS(ns: string, session: NReplSession, nss: string[]): Promise<string[]> {
if (!ns.endsWith('-test')) {
const testNS = ns + '-test';
const testFilePath = (await session.nsPath(testNS)).path;
const nsPath = await session.nsPath(testNS);
const testFilePath = nsPath.path;
if (testFilePath && testFilePath !== "") {
const filePath = removeFileSchemeFromUri(testFilePath);
const filePath = vscode.Uri.parse(testFilePath).path;
let loadForms = `(load-file "${filePath}")`;
await session.eval(loadForms, testNS).value;
}
Expand Down
7 changes: 1 addition & 6 deletions src/util/string.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,9 @@ function getTextAfterLastOccurrenceOfSubstring(text: string, substring: string):
return text.substring(indexOfEndOfPrompt);
}

function removeFileSchemeFromUri(uri: string): string {
return uri.replace(/^(file:)/, '');
}

export {
keywordize,
unKeywordize,
getIndexAfterLastNonWhitespace,
getTextAfterLastOccurrenceOfSubstring,
removeFileSchemeFromUri
getTextAfterLastOccurrenceOfSubstring
}