Skip to content

Commit 34642e8

Browse files
authored
Fix table/plots not updating correctly on windows (#3191)
1 parent 6fe32b5 commit 34642e8

File tree

8 files changed

+42
-42
lines changed

8 files changed

+42
-42
lines changed

extension/src/data/index.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
import { relative } from 'path'
22
import { EventEmitter, Event } from 'vscode'
3-
import {
4-
createFileSystemWatcher,
5-
getRelativePattern
6-
} from '../fileSystem/watcher'
3+
import { getRelativePattern } from '../fileSystem/relativePattern'
4+
import { createFileSystemWatcher } from '../fileSystem/watcher'
75
import { ProcessManager } from '../processManager'
86
import { InternalCommands } from '../commands/internal'
97
import { ExperimentsOutput, PlotsOutputOrError } from '../cli/dvc/contract'

extension/src/experiments/data/index.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,8 @@ import {
66
EXPERIMENTS_GIT_REFS,
77
EXPERIMENTS_GIT_REFS_EXEC
88
} from './constants'
9-
import {
10-
createFileSystemWatcher,
11-
getRelativePattern
12-
} from '../../fileSystem/watcher'
9+
import { getRelativePattern } from '../../fileSystem/relativePattern'
10+
import { createFileSystemWatcher } from '../../fileSystem/watcher'
1311
import { AvailableCommands, InternalCommands } from '../../commands/internal'
1412
import { ExperimentsOutput } from '../../cli/dvc/contract'
1513
import { BaseData } from '../../data'

extension/src/fileSystem/data/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@ import { join } from 'path'
22
import { Event, EventEmitter } from 'vscode'
33
import { isSameOrChild, loadYaml, PartialDvcYaml } from '..'
44
import { findFiles } from '../workspace'
5-
import { createFileSystemWatcher, getRelativePattern } from '../watcher'
5+
import { getRelativePattern } from '../relativePattern'
6+
import { createFileSystemWatcher } from '../watcher'
67
import { DeferredDisposable } from '../../class/deferred'
78

89
export class FileSystemData extends DeferredDisposable {
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import { relative } from 'path'
2+
import { RelativePattern, Uri, workspace } from 'vscode'
3+
import { isSameOrChild } from '.'
4+
5+
const joinWithForwardSlashes = (strings: string[]) =>
6+
strings.filter(Boolean).join('/')
7+
8+
const getRelativePatternForOutsideWorkspace = (
9+
uri: Uri,
10+
pattern: string
11+
): RelativePattern => new RelativePattern(uri, pattern)
12+
13+
export const getRelativePattern = (
14+
path: string,
15+
pattern: string
16+
): RelativePattern => {
17+
for (const workspaceFolder of workspace.workspaceFolders || []) {
18+
const workspaceFolderPath = workspaceFolder.uri.fsPath
19+
if (isSameOrChild(workspaceFolderPath, path)) {
20+
return new RelativePattern(
21+
workspaceFolder,
22+
joinWithForwardSlashes([relative(workspaceFolderPath, path), pattern])
23+
)
24+
}
25+
}
26+
27+
return getRelativePatternForOutsideWorkspace(Uri.file(path), pattern)
28+
}

extension/src/fileSystem/watcher.ts

Lines changed: 2 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,7 @@
1-
import { join, relative } from 'path'
21
import { utimes } from 'fs-extra'
3-
import { GlobPattern, RelativePattern, Uri, workspace } from 'vscode'
2+
import { GlobPattern, workspace } from 'vscode'
43
import { Disposable } from '@hediet/std/disposable'
5-
import { isDirectory, isSameOrChild } from '.'
6-
7-
const getRelativePatternForOutsideWorkspace = (
8-
uri: Uri,
9-
pattern: string
10-
): RelativePattern => new RelativePattern(uri, pattern)
11-
12-
export const getRelativePattern = (
13-
path: string,
14-
pattern: string
15-
): RelativePattern => {
16-
for (const workspaceFolder of workspace.workspaceFolders || []) {
17-
const workspaceFolderPath = workspaceFolder.uri.fsPath
18-
if (isSameOrChild(workspaceFolderPath, path)) {
19-
return new RelativePattern(
20-
workspaceFolder,
21-
join(relative(workspaceFolderPath, path), pattern)
22-
)
23-
}
24-
}
25-
26-
return getRelativePatternForOutsideWorkspace(Uri.file(path), pattern)
27-
}
4+
import { isDirectory } from '.'
285

296
export const fireWatcher = (path: string): Promise<void> => {
307
const now = Date.now() / 1000

extension/src/repository/data/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import { Event, EventEmitter } from 'vscode'
22
import { AvailableCommands, InternalCommands } from '../../commands/internal'
33
import { ProcessManager } from '../../processManager'
4+
import { getRelativePattern } from '../../fileSystem/relativePattern'
45
import {
56
createFileSystemWatcher,
6-
ignoredDotDirectories,
7-
getRelativePattern
7+
ignoredDotDirectories
88
} from '../../fileSystem/watcher'
99
import {
1010
EXPERIMENTS_GIT_LOGS_REFS,

extension/src/setup/index.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,8 @@ import { WorkspaceExperiments } from '../experiments/workspace'
3737
import { DvcRunner } from '../cli/dvc/runner'
3838
import { sendTelemetryEvent, sendTelemetryEventAndThrow } from '../telemetry'
3939
import { StopWatch } from '../util/time'
40-
import {
41-
createFileSystemWatcher,
42-
getRelativePattern
43-
} from '../fileSystem/watcher'
40+
import { getRelativePattern } from '../fileSystem/relativePattern'
41+
import { createFileSystemWatcher } from '../fileSystem/watcher'
4442
import { EventName } from '../telemetry/constants'
4543
import { WorkspaceScale } from '../telemetry/collect'
4644
import { gitPath } from '../cli/git/constants'

extension/src/test/suite/fileSystem/watcher.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { expect } from 'chai'
44
import { Uri } from 'vscode'
55
import { Disposable } from '@hediet/std/disposable'
66
import { restore } from 'sinon'
7-
import { getRelativePattern } from '../../../fileSystem/watcher'
7+
import { getRelativePattern } from '../../../fileSystem/relativePattern'
88
import { dvcDemoPath, getTestWorkspaceFolder } from '../../util'
99

1010
suite('File System Watcher Test Suite', () => {
@@ -27,7 +27,7 @@ suite('File System Watcher Test Suite', () => {
2727
expect(relativePattern.baseUri).to.deep.equal(
2828
getTestWorkspaceFolder().uri
2929
)
30-
expect(relativePattern.pattern).equal(join('.git', '**'))
30+
expect(relativePattern.pattern).equal('.git/**')
3131
})
3232

3333
it('should return the expected relative pattern for a path outside of the workspace', () => {

0 commit comments

Comments
 (0)