Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ const eslintConfig = defineConfig([
'build/',
'next-env.d.ts',
'branch-*/',
// Ignore vendored microsoft/vscode typing files

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI textDocumentChangeReason isn't vendored, it's a custom extension we patch into code-server

'vscode-workbench/src/vscode.proposed.*.d.ts',
]),
{
plugins: {
Expand Down
5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@
"tsc:collab-server": "npm --workspace collab-server run tsc",
"tsc:vscode-workbench": "npm --workspace vscode-workbench run tsc",
"tsc:workbench-app": "tsc",
"lint": "prettier --check . && eslint"
"lint": "prettier --check . && eslint",
"lint:fix": "prettier --write . && eslint . --fix",
"prettier": "prettier --check .",
"prettier:fix": "prettier --write ."
},
"dependencies": {
"@hocuspocus/provider": "^4.0.0",
Expand Down
1 change: 1 addition & 0 deletions scripts/hmr-nudge.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

import { createHash } from 'node:crypto'
import { readFile, utimes } from 'node:fs/promises'

import chokidar from 'chokidar'

const paths = process.argv.length < 3 ? ['src'] : process.argv.slice(2)
Expand Down
2 changes: 1 addition & 1 deletion vscode-workbench/src/vscode.proposed.extensionsAny.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
declare module 'vscode' {
// https://github.com/microsoft/vscode/issues/145307 @alexdima

export interface Extension<_T> {
export interface Extension<T> {
/**
* `true` when the extension is associated to another extension host.
*
Expand Down
24 changes: 12 additions & 12 deletions vscode-workbench/test/collab.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { Logger } from '../src/util'

const delay = (ms: number) => new Promise<void>(r => setTimeout(r, ms))

const logLevel: vs.LogLevel = vs.LogLevel.Debug as unknown as vs.LogLevel // cast prevents TS from complaining
const logLevel = vs.LogLevel.Debug as vs.LogLevel // cast prevents TS from complaining
const consoleLog: Logger = {
logLevel,
trace: (m, ...a) => {
Expand Down Expand Up @@ -132,14 +132,14 @@ suite('Collaborative editing', () => {
vs.workspace.openTextDocument({ content: '', language: 'plaintext' }),
])
const bindings = docs.map(
(doc, i) => new YTextBinding(doc, clients[i], consoleLog, true, ensureSyncTimeoutMs, DOC_NAME),
(doc, i) => new YTextBinding(doc, clients[i]!, consoleLog, true, ensureSyncTimeoutMs, DOC_NAME),
)

// Route document changes to the matching binding
// (`YTextBindingManager.onDidChangeTextDocument` does this in production).
const changeSub = vs.workspace.onDidChangeTextDocument(e => {
const i = docs.indexOf(e.document)
if (i >= 0) bindings[i].onLocalChange(e)
if (i >= 0) bindings[i]!.onLocalChange(e)
})

return {
Expand All @@ -166,12 +166,12 @@ suite('Collaborative editing', () => {
await waitForInitialSync(handles.bindings, 1_000)

// Type on doc0 and confirm the change reaches doc1.
const ed0 = await vs.window.showTextDocument(handles.docs[0], { viewColumn: COLUMNS[0], preview: false })
const ed0 = await vs.window.showTextDocument(handles.docs[0]!, { viewColumn: COLUMNS[0], preview: false })
ed0.selection = new vs.Selection(0, 0, 0, 0)
const text = 'PROBE\n'
await vs.commands.executeCommand('default:type', { text })
await waitForQuiescence(handles.bindings, 1_000)
assert.strictEqual(handles.docs[1].getText(), text)
assert.strictEqual(handles.docs[1]!.getText(), text)
await handles.dispose()
})

Expand All @@ -181,7 +181,7 @@ suite('Collaborative editing', () => {
const rng = mulberry32(0xc0ffee)
const NUM_EDITS = 100
for (let i = 0; i < NUM_EDITS; i++) {
await randomEditOn(handles.docs[i % 2], COLUMNS[i % 2], rng)
await randomEditOn(handles.docs[i % 2]!, COLUMNS[i % 2]!, rng)
}
}

Expand All @@ -190,10 +190,10 @@ suite('Collaborative editing', () => {
const [y0, y1] = handles.bindings.map(b => b.remoteYtext.toString())

// Sanity check - YJs CRDT replicas converge.
assert.strictEqual(y0, y1, diffMessage('Y.Text replicas (client0 vs client1)', y0, y1))
assert.strictEqual(y0, y1, diffMessage('Y.Text replicas (client0 vs client1)', y0!, y1!))
// Whether docs correctly track CRDT replicas.
assert.strictEqual(d0, y0, diffMessage('doc0 vs its Y.Text', d0, y0))
assert.strictEqual(d1, y1, diffMessage('doc1 vs its Y.Text', d1, y1))
assert.strictEqual(d0, y0, diffMessage('doc0 vs its Y.Text', d0!, y0!))
assert.strictEqual(d1, y1, diffMessage('doc1 vs its Y.Text', d1!, y1!))
}

test('Concurrent edits settle on equal states', async function () {
Expand All @@ -214,11 +214,11 @@ suite('Collaborative editing', () => {
await waitForInitialSync(handles.bindings, 1_000)
// Ensure both documents are visible:
// only `TextEditor.edit`s are expected to converge without ensureSync.
await vs.window.showTextDocument(handles.docs[0], { viewColumn: COLUMNS[0], preview: false })
await vs.window.showTextDocument(handles.docs[1], { viewColumn: COLUMNS[1], preview: false })
await vs.window.showTextDocument(handles.docs[0]!, { viewColumn: COLUMNS[0], preview: false })
await vs.window.showTextDocument(handles.docs[1]!, { viewColumn: COLUMNS[1], preview: false })
await makeConcurrentEdits(handles)
await waitForQuiescence(handles.bindings, 3_000)
await assertEqualStates(handles)
assertEqualStates(handles)
await handles.dispose()
})
})
Loading