@lvce-editor/output-view 2.16.0 → 2.17.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1429,20 +1429,30 @@ const parseStructuredLogLine = line => {
1429
1429
  }, {
1430
1430
  className: OutputSourceLink,
1431
1431
  label: getSourceLabel(parsed.source, parsed.line),
1432
+ lineNumber: parsed.line,
1432
1433
  type: Link,
1433
1434
  value: parsed.source
1434
1435
  }];
1435
1436
  };
1436
1437
 
1437
1438
  const RE_SOURCE_LINK = /^lvce(?:-oss)?:\/\//;
1438
- const RE_SOURCE_LOCATION = /:\d+(?::\d+)?$/;
1439
+ const RE_SOURCE_LOCATION = /:(\d+)(?::(\d+))?$/;
1439
1440
  const getLinkPart = match => {
1440
1441
  if (RE_SOURCE_LINK.test(match)) {
1442
+ const locationMatch = match.match(RE_SOURCE_LOCATION);
1443
+ const lineNumber = locationMatch ? Number(locationMatch[1]) : undefined;
1444
+ const columnNumber = locationMatch?.[2] ? Number(locationMatch[2]) : undefined;
1441
1445
  return {
1442
1446
  className: OutputSourceLink,
1447
+ ...(columnNumber !== undefined && {
1448
+ columnNumber
1449
+ }),
1443
1450
  label: match,
1451
+ ...(lineNumber !== undefined && {
1452
+ lineNumber
1453
+ }),
1444
1454
  type: Link,
1445
- value: match.replace(RE_SOURCE_LOCATION, '')
1455
+ value: locationMatch ? match.slice(0, -locationMatch[0].length) : match
1446
1456
  };
1447
1457
  }
1448
1458
  return {
@@ -1904,11 +1914,21 @@ const handleSelect = async (state, id) => {
1904
1914
  return selectChannel(state, id);
1905
1915
  };
1906
1916
 
1907
- const handleSourceLinkClick = async (state, uri) => {
1917
+ const handleSourceLinkClick = async (state, uri, lineNumber, columnNumber) => {
1908
1918
  if (!uri) {
1909
1919
  return state;
1910
1920
  }
1911
- await invoke('Main.openUri', uri);
1921
+ const line = Number(lineNumber);
1922
+ if (!Number.isSafeInteger(line) || line <= 0) {
1923
+ await invoke('Main.openUri', uri);
1924
+ return state;
1925
+ }
1926
+ const column = Number(columnNumber);
1927
+ const rowIndex = line - 1;
1928
+ const columnIndex = Number.isSafeInteger(column) && column > 0 ? column - 1 : 0;
1929
+ await invoke('Main.openUri', uri, true, {
1930
+ selections: new Uint32Array([rowIndex, columnIndex, rowIndex, columnIndex])
1931
+ });
1912
1932
  return state;
1913
1933
  };
1914
1934
 
@@ -2215,6 +2235,12 @@ const getLinePartDom = part => {
2215
2235
  ...(part.className && {
2216
2236
  className: part.className
2217
2237
  }),
2238
+ ...(part.columnNumber !== undefined && {
2239
+ 'data-column': part.columnNumber
2240
+ }),
2241
+ ...(part.lineNumber !== undefined && {
2242
+ 'data-line': part.lineNumber
2243
+ }),
2218
2244
  ...(isSourceLink && {
2219
2245
  onClick: HandleSourceLinkClick
2220
2246
  })
@@ -2464,7 +2490,7 @@ const renderEventListeners = () => {
2464
2490
  params: ['clearFilter']
2465
2491
  }, {
2466
2492
  name: HandleSourceLinkClick,
2467
- params: ['handleSourceLinkClick', 'event.target.href'],
2493
+ params: ['handleSourceLinkClick', 'event.target.href', 'event.target.dataset.line', 'event.target.dataset.column'],
2468
2494
  preventDefault: true
2469
2495
  }, {
2470
2496
  name: HandlePointerDown,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/output-view",
3
- "version": "2.16.0",
3
+ "version": "2.17.1",
4
4
  "description": "Output View Worker",
5
5
  "repository": {
6
6
  "type": "git",