diff --git a/CHANGELOG.md b/CHANGELOG.md index 27ae6e023..66f8dadc9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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) diff --git a/src/debugger/calva-debug.ts b/src/debugger/calva-debug.ts index b3c18f627..d883e9ae0 100644 --- a/src/debugger/calva-debug.ts +++ b/src/debugger/calva-debug.ts @@ -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', @@ -177,8 +176,7 @@ class CalvaDebugSession extends LoggingDebugSession { protected async stackTraceRequest(response: DebugProtocol.StackTraceResponse, args: DebugProtocol.StackTraceArguments, request?: DebugProtocol.Request): Promise { 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)); @@ -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)]; diff --git a/src/extension-test/unit/util/string-test.ts b/src/extension-test/unit/util/string-test.ts index d35a806b4..539380681 100644 --- a/src/extension-test/unit/util/string-test.ts +++ b/src/extension-test/unit/util/string-test.ts @@ -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', () => { @@ -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'); - }); - }); }); \ No newline at end of file diff --git a/src/testRunner.ts b/src/testRunner.ts index f1bc0b22a..189e146e2 100644 --- a/src/testRunner.ts +++ b/src/testRunner.ts @@ -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'); @@ -121,9 +120,10 @@ function runAllTestsCommand() { async function considerTestNS(ns: string, session: NReplSession, nss: string[]): Promise { 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; } diff --git a/src/util/string.ts b/src/util/string.ts index 394acdf3f..83f8c54dc 100644 --- a/src/util/string.ts +++ b/src/util/string.ts @@ -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 } \ No newline at end of file