|
1 | 1 | 'use strict'; |
2 | 2 |
|
3 | 3 | import { Comment, CommentReaction, CommentThread, Range } from 'vscode'; |
4 | | -import { fullPathtoRelative } from '../../utils'; |
| 4 | +import { fullPathToRelative, isWindows, pathToPosix, pathToWin32 } from '../../utils'; |
5 | 5 | import { Resource } from '../../reactions/resource'; |
6 | 6 |
|
7 | 7 | export class Serializer { |
8 | 8 | static serializeReaction(reaction: CommentReaction) { |
| 9 | + let iconPath = fullPathToRelative( |
| 10 | + typeof reaction.iconPath === 'string' |
| 11 | + ? reaction.iconPath |
| 12 | + : reaction.iconPath.fsPath, |
| 13 | + Resource.extensionPath, |
| 14 | + ); |
| 15 | + if (isWindows()) { |
| 16 | + iconPath = pathToPosix(iconPath); |
| 17 | + } |
9 | 18 | return { |
10 | 19 | count: reaction.count, |
11 | | - iconPath: fullPathtoRelative( |
12 | | - typeof reaction.iconPath === 'string' |
13 | | - ? reaction.iconPath |
14 | | - : reaction.iconPath.fsPath, |
15 | | - Resource.extensionPath, |
16 | | - ), |
| 20 | + iconPath: iconPath, |
17 | 21 | label: reaction.label, |
18 | 22 | }; |
19 | 23 | } |
@@ -45,9 +49,13 @@ export class Serializer { |
45 | 49 | thread.comments.forEach((comment) => { |
46 | 50 | serializedComments.push(this.serializeComment(comment)); |
47 | 51 | }); |
| 52 | + let uri = fullPathToRelative(thread.uri.path); |
| 53 | + if (isWindows()) { |
| 54 | + uri = pathToPosix(uri); |
| 55 | + } |
48 | 56 | return { |
49 | 57 | range: this.serializeRange(thread.range), |
50 | | - uri: fullPathtoRelative(thread.uri.path), |
| 58 | + uri: uri, |
51 | 59 | comments: serializedComments, |
52 | 60 | id: thread.contextValue, |
53 | 61 | }; |
|
0 commit comments