Skip to content

Commit

Permalink
Merge branch '#234' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
zero-plusplus committed Jul 13, 2022
2 parents bba34e3 + bd582a5 commit 4952b78
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 12 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ Also want to check the development status, check the [commit history](https://gi
* [#220](https://github.com/zero-plusplus/vscode-autohotkey-debug/issues/220) Grouping of messages using Debug Directive is not working, such as `; @Debug-Output:start`, `; @Debug-Output:end`
* [#229](https://github.com/zero-plusplus/vscode-autohotkey-debug/issues/229) Raw error message on Critical Error
* [#232](https://github.com/zero-plusplus/vscode-autohotkey-debug/issues/232) Output of members in bracketed notation in Output directive, Watch expression, etc. may not be evaluated correctly
* [#234](https://github.com/zero-plusplus/vscode-autohotkey-debug/issues/234) Breakpoint do not work when `runtime` is a UNC path (e.g. `//server/folder`)

## [1.11.0] - 2022-02-11
### Added
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ This extension is a debugger adapter for [VSCode](https://code.visualstudio.com/
* Fixed: [#220](https://github.com/zero-plusplus/vscode-autohotkey-debug/issues/220) Grouping of messages using Debug Directive is not working, such as `; @Debug-Output:start`, `; @Debug-Output:end`
* Fixed: [#229](https://github.com/zero-plusplus/vscode-autohotkey-debug/issues/229) Raw error message on Critical Error
* Fixed: [#232](https://github.com/zero-plusplus/vscode-autohotkey-debug/issues/232) Output of members in bracketed notation in Output directive, Watch expression, etc. may not be evaluated correctly
* Fixed: [#234](https://github.com/zero-plusplus/vscode-autohotkey-debug/issues/234) Breakpoint do not work when `runtime` is a UNC path (e.g. `//server/folder`)

* `1.11.0` - 2022-02-11
* Added: [#201](https://github.com/zero-plusplus/vscode-autohotkey-debug/issues/201) Add `useLoadedScripts` to launch.json
Expand Down
5 changes: 3 additions & 2 deletions src/ahkDebug.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ import { TraceLogger } from './util/TraceLogger';
import { completionItemProvider } from './CompletionItemProvider';
import * as dbgp from './dbgpSession';
import { AutoHotkeyLauncher, AutoHotkeyProcess } from './util/AutoHotkeyLuncher';
import { isPrimitive, now, timeoutPromise } from './util/util';
import { isPrimitive, now, timeoutPromise, toFileUri } from './util/util';
import matcher from 'matcher';
import { Categories, Category, MetaVariable, MetaVariableValue, MetaVariableValueMap, Scope, StackFrames, Variable, VariableManager, formatProperty } from './util/VariableManager';
import { CategoryData } from './extension';
Expand Down Expand Up @@ -303,7 +303,8 @@ export class AhkDebugSession extends LoggingDebugSession {
}

const filePath = args.source.path ?? '';
const fileUri = URI.file(filePath).toString();
const fileUri = toFileUri(filePath);

const removedBreakpoints = await this.breakpointManager!.unregisterBreakpointsInFile(fileUri);

const vscodeBreakpoints: DebugProtocol.Breakpoint[] = [];
Expand Down
6 changes: 3 additions & 3 deletions src/dbgpSession.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import convertHrTime from 'convert-hrtime';
import { uniq, uniqBy } from 'lodash';
import { AhkVersion } from '@zero-plusplus/autohotkey-utilities';
import { CaseInsensitiveMap } from './util/CaseInsensitiveMap';
import { isNumberLike, joinVariablePathArray, splitVariablePath } from './util/util';
import { isNumberLike, joinVariablePathArray, splitVariablePath, toFileUri } from './util/util';
import { equalsIgnoreCase } from './util/stringUtils';
import { TraceLogger } from './util/TraceLogger';
import { isComObject, unescapeAhk } from './util/VariableManager';
Expand Down Expand Up @@ -410,7 +410,7 @@ export class Breakpoint {
this.id = parseInt(id, 10);
this.type = type as BreakpointType;
this.state = state as BreakpointState;
this.fileUri = filename;
this.fileUri = toFileUri(filename);
this.line = parseInt(lineno, 10);
this.temporary = Boolean(parseInt(temporary, 10));
}
Expand Down Expand Up @@ -667,7 +667,7 @@ export class Session extends EventEmitter {
return new BreakpointGetResponse(await this.sendCommand('breakpoint_get', `-d ${breakpointId}`));
}
public async sendBreakpointSetCommand(fileUri: string, line: number): Promise<BreakpointSetResponse> {
return new BreakpointSetResponse(await this.sendCommand('breakpoint_set', `-t line -f ${fileUri} -n ${line}`));
return new BreakpointSetResponse(await this.sendCommand('breakpoint_set', `-t line -f ${toFileUri(fileUri)} -n ${line}`));
}
public async sendBreakpointRemoveCommand(id: number): Promise<Response> {
return new Response(await this.sendCommand('breakpoint_remove', `-d ${id}`));
Expand Down
10 changes: 5 additions & 5 deletions src/util/BreakpointManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import * as dbgp from '../dbgpSession';
import { URI } from 'vscode-uri';
import { CaseInsensitiveMap } from './CaseInsensitiveMap';
import { equalsIgnoreCase } from './stringUtils';
import { toFileUri } from './util';

export type BreakpointLogGroup = 'start' | 'startCollapsed' | 'end' | undefined;
export interface BreakpointAdvancedData {
Expand Down Expand Up @@ -101,7 +102,7 @@ export class BreakpointManager {
public getLineBreakpoints(fileUri: string, line: number): LineBreakpoints | null {
const key = this.createKey(fileUri, line);
for (const [ targetKey, lineBreakpoints ] of this.breakpointsMap) {
if (key === targetKey) {
if (equalsIgnoreCase(key, targetKey)) {
return lineBreakpoints;
}
}
Expand Down Expand Up @@ -187,13 +188,12 @@ export class BreakpointManager {
}
return removedBreakpoints;
}
private createKey(fileUri: string, line: number): string {
private createKey(file: string, line: number): string {
// The following encoding differences have been converted to path
// file:///W%3A/project/vscode-autohotkey-debug/demo/demo.ahk"
// file:///w:/project/vscode-autohotkey-debug/demo/demo.ahk

const uri = URI.parse(fileUri);
const filePath = uri.scheme === 'file' ? uri.fsPath.toLowerCase() : fileUri.toLowerCase();
return `${filePath},${line}`;
const fileUri = toFileUri(file);
return `${fileUri},${line}`;
}
}
4 changes: 2 additions & 2 deletions src/util/VariableManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { URI } from 'vscode-uri';
import * as dbgp from '../dbgpSession';
import { rtrim } from 'underscore.string';
import { AhkVersion } from '@zero-plusplus/autohotkey-utilities';
import { isNumberLike, isPrimitive, toArray } from './util';
import { isNumberLike, isPrimitive, toArray, toFileUri } from './util';
import { equalsIgnoreCase } from './stringUtils';
import { CategoryData, MatcherData, ScopeSelector } from '../extension';
import { CaseInsensitiveMap } from './CaseInsensitiveMap';
Expand Down Expand Up @@ -127,7 +127,7 @@ export class StackFrame implements DebugProtocol.StackFrame {
this.id = handles.create(this);
this.name = dbgpStackFrame.name;
this.line = dbgpStackFrame.line;
const filePath = URI.parse(dbgpStackFrame.fileUri).fsPath;
const filePath = URI.parse(toFileUri(dbgpStackFrame.fileUri)).fsPath;
this.source = new DebugAdapter.Source(path.basename(filePath), filePath);

this.session = session;
Expand Down
19 changes: 19 additions & 0 deletions src/util/util.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/* eslint-disable @typescript-eslint/explicit-module-boundary-types */
import { AhkVersion } from '@zero-plusplus/autohotkey-utilities';
import { statSync } from 'fs';
import { URI } from 'vscode-uri';

export const isDirectory = (dirPath): boolean => {
try {
Expand Down Expand Up @@ -161,3 +162,21 @@ export const now = (): string => {
const milliSeconds = String(now.getMilliseconds()).padStart(3, '0');
return `${now.getFullYear()}/${month}/${date} ${hours}:${minutes}:${seconds}.${milliSeconds}`;
};

export const toFileUri = (file: string): string => {
const isUncPath = file.startsWith('\\\\');
if (isUncPath) {
return file;
}

const isUri = file.startsWith('file:');
if (isUri) {
const isUncUri = (/^file:\/\/\/(?!\w%3A)/iu).test(file);
if (isUncUri) {
return `${file.replace(/^file:\/\/(\/)?/u, '')}`;
}
return file;
}

return URI.file(file).toString();
};

0 comments on commit 4952b78

Please sign in to comment.