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
3 changes: 3 additions & 0 deletions .github/copilot-instructions.md
Original file line number Diff line number Diff line change
Expand Up @@ -137,3 +137,6 @@ function f(x: number, y: string): void { }
- When adding file watching, prefer correlated file watchers (via fileService.createWatcher) to shared ones.
- When adding tooltips to UI elements, prefer the use of IHoverService service.
- Do not duplicate code. Always look for existing utility functions, helpers, or patterns in the codebase before implementing new functionality. Reuse and extend existing code whenever possible.

## Learnings
- Minimize the amount of assertions in tests. Prefer one snapshot-style `assert.deepStrictEqual` over multiple precise assertions, as they are much more difficult to understand and to update.
10 changes: 3 additions & 7 deletions .github/instructions/learnings.instructions.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,25 +8,21 @@ It is a meta-instruction file.

Structure of learnings:
* Each instruction file has a "Learnings" section.
* Each learning has a counter that indicates how often that learning was useful (initially 1).
* Each learning has a 1-4 sentences description of the learning.

Example:
```markdown
## Learnings
* Prefer `const` over `let` whenever possible (1)
* Avoid `any` type (3)
* Prefer `const` over `let` whenever possible
* Avoid `any` type
```

When the user tells you "learn!", you should:
* extract a learning from the recent conversation
* identify the problem that you created
* identify why it was a problem
* identify how you were told to fix it/how the user fixed it
* reflect over it, maybe it can be generalized? Avoid too specific learnings.
* create a learning (1-4 sentences) from that
* Write this out to the user and reflect over these sentences
* then, add the reflected learning to the "Learnings" section of the most appropriate instruction file


Important: Whenever a learning was really useful, increase the counter!!
When a learning was not useful and just caused more problems, decrease the counter.
51 changes: 31 additions & 20 deletions build/azure-pipelines/common/sanity-tests.yml
Original file line number Diff line number Diff line change
@@ -1,61 +1,72 @@
parameters:
- name: commit
- name: name
type: string
- name: quality
- name: displayName
type: string
- name: poolName
type: string
- name: os
type: string
- name: args
type: string
default: ""

jobs:
- job: ${{ parameters.os }}
displayName: ${{ parameters.os }} Sanity Tests
- job: ${{ parameters.name }}
displayName: ${{ parameters.displayName }}
pool:
name: ${{ parameters.poolName }}
os: ${{ parameters.os }}
timeoutInMinutes: 30
variables:
SANITY_TEST_LOGS: $(Build.SourcesDirectory)/.build/sanity-test-logs
LOG_FILE: $(SANITY_TEST_LOGS)/results.xml
templateContext:
outputs:
- output: pipelineArtifact
targetPath: $(SANITY_TEST_LOGS)
artifactName: sanity-test-logs-${{ lower(parameters.os) }}-$(System.JobAttempt)
displayName: Publish Sanity Test Logs
artifactName: sanity-test-logs-${{ parameters.name }}-$(System.JobAttempt)
displayName: Sanity Tests Logs
sbomEnabled: false
isProduction: false
condition: succeededOrFailed()
steps:
- checkout: self
- template: ./checkout.yml@self

- task: NodeTool@0
inputs:
versionSource: fromFile
versionFilePath: .nvmrc
displayName: Install Node.js

- ${{ if eq(parameters.os, 'windows') }}:
- script: |
mkdir "$(SANITY_TEST_LOGS)"
displayName: Create Logs Directory
- bash: |
npm config set registry "$(NPM_REGISTRY)"
echo "##vso[task.setvariable variable=NPMRC_PATH]$(npm config get userconfig)"
condition: and(succeeded(), ne(variables['NPM_REGISTRY'], 'none'))
displayName: Configure NPM Registry

- ${{ else }}:
- script: |
mkdir -p "$(SANITY_TEST_LOGS)"
displayName: Create Logs Directory
- task: npmAuthenticate@0
inputs:
workingFile: $(NPMRC_PATH)
condition: and(succeeded(), ne(variables['NPM_REGISTRY'], 'none'))
displayName: Authenticate with NPM Registry

- script: npm install
- script: npm ci
workingDirectory: ./test/sanity
displayName: Install Dependencies
workingDirectory: $(Build.SourcesDirectory)/test/sanity

- script: npm run sanity-test -- --commit ${{ parameters.commit }} --quality ${{ parameters.quality }} --verbose --test-results $(SANITY_TEST_LOGS)/sanity-test.xml
- script: npm run compile
workingDirectory: ./test/sanity
displayName: Compile Sanity Tests

- script: npm run start -- -c $(BUILD_COMMIT) -q $(BUILD_QUALITY) -t $(LOG_FILE) -v ${{ parameters.args }}
workingDirectory: ./test/sanity
displayName: Run Sanity Tests

- task: PublishTestResults@2
inputs:
testResultsFormat: JUnit
testResultsFiles: $(SANITY_TEST_LOGS)/sanity-test.xml
testRunTitle: ${{ parameters.os }} Sanity Tests
testResultsFiles: $(LOG_FILE)
testRunTitle: ${{ parameters.displayName }}
condition: succeededOrFailed()
displayName: Publish Test Results
50 changes: 36 additions & 14 deletions build/azure-pipelines/product-sanity-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,37 @@ pr: none
trigger: none

parameters:
- name: commit
displayName: Commit
- name: BUILD_COMMIT
displayName: Published Build Commit
type: string
- name: quality
displayName: Quality

- name: BUILD_QUALITY
displayName: Published Build Quality
type: string
default: insider
values:
- exploration
- insider
- stable

- name: NPM_REGISTRY
displayName: Custom NPM Registry URL
type: string
default: "https://pkgs.dev.azure.com/monacotools/Monaco/_packaging/vscode/npm/registry/"

variables:
- name: skipComponentGovernanceDetection
value: true
- name: Codeql.SkipTaskAutoInjection
value: true
- name: BUILD_COMMIT
value: ${{ parameters.BUILD_COMMIT }}
- name: BUILD_QUALITY
value: ${{ parameters.BUILD_QUALITY }}
- name: NPM_REGISTRY
value: ${{ parameters.NPM_REGISTRY }}

name: "$(Date:yyyyMMdd).$(Rev:r) (${{ parameters.quality }})"
name: "$(Date:yyyyMMdd).$(Rev:r) (${{ parameters.BUILD_QUALITY }} ${{ parameters.BUILD_COMMIT }})"

resources:
repositories:
Expand All @@ -47,25 +59,35 @@ extends:
sourceAnalysisPool: 1es-windows-2022-x64
createAdoIssuesForJustificationsForDisablement: false
stages:
- stage: SanityTests
- stage: sanity_tests
displayName: Run Sanity Tests
jobs:
- template: build/azure-pipelines/common/sanity-tests.yml@self
parameters:
commit: ${{ parameters.commit }}
quality: ${{ parameters.quality }}
name: Windows_x64
displayName: Windows x64 Sanity Tests
poolName: 1es-windows-2022-x64
os: windows

- template: build/azure-pipelines/common/sanity-tests.yml@self
parameters:
name: Windows_arm64
displayName: Windows arm64 Sanity Tests (no runtime)
poolName: 1es-windows-2022-x64
os: windows
args: --no-runtime-check --grep "win32-arm64"

- template: build/azure-pipelines/common/sanity-tests.yml@self
parameters:
commit: ${{ parameters.commit }}
quality: ${{ parameters.quality }}
poolName: 1es-ubuntu-22.04-x64
os: linux
name: macOS_x64
displayName: MacOS x64 Sanity Tests (no runtime)
poolName: AcesShared
os: macOS
args: --no-runtime-check --grep "darwin-x64"

- template: build/azure-pipelines/common/sanity-tests.yml@self
parameters:
commit: ${{ parameters.commit }}
quality: ${{ parameters.quality }}
name: macOS_arm64
displayName: MacOS arm64 Sanity Tests
poolName: AcesShared
os: macOS
4 changes: 3 additions & 1 deletion extensions/git/src/api/api1.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import { Model } from '../model';
import { Repository as BaseRepository, Resource } from '../repository';
import { InputBox, Git, API, Repository, Remote, RepositoryState, Branch, ForcePushMode, Ref, Submodule, Commit, Change, RepositoryUIState, Status, LogOptions, APIState, CommitOptions, RefType, CredentialsProvider, BranchQuery, PushErrorHandler, PublishEvent, FetchOptions, RemoteSourceProvider, RemoteSourcePublisher, PostCommitCommandsProvider, RefQuery, BranchProtectionProvider, InitOptions, SourceControlHistoryItemDetailsProvider, GitErrorCodes, CloneOptions, CommitShortStat, DiffChange, Worktree } from './git';
import { InputBox, Git, API, Repository, Remote, RepositoryState, Branch, ForcePushMode, Ref, Submodule, Commit, Change, RepositoryUIState, Status, LogOptions, APIState, CommitOptions, RefType, CredentialsProvider, BranchQuery, PushErrorHandler, PublishEvent, FetchOptions, RemoteSourceProvider, RemoteSourcePublisher, PostCommitCommandsProvider, RefQuery, BranchProtectionProvider, InitOptions, SourceControlHistoryItemDetailsProvider, GitErrorCodes, CloneOptions, CommitShortStat, DiffChange, Worktree, RepositoryKind } from './git';
import { Event, SourceControlInputBox, Uri, SourceControl, Disposable, commands, CancellationToken } from 'vscode';
import { combinedDisposable, filterEvent, mapEvent } from '../util';
import { toGitUri } from '../uri';
Expand Down Expand Up @@ -78,6 +78,7 @@ export class ApiRepository implements Repository {

readonly rootUri: Uri;
readonly inputBox: InputBox;
readonly kind: RepositoryKind;
readonly state: RepositoryState;
readonly ui: RepositoryUIState;

Expand All @@ -87,6 +88,7 @@ export class ApiRepository implements Repository {
constructor(repository: BaseRepository) {
this.#repository = repository;

this.kind = this.#repository.kind;
this.rootUri = Uri.file(this.#repository.root);
this.inputBox = new ApiInputBox(this.#repository.inputBox);
this.state = new ApiRepositoryState(this.#repository);
Expand Down
2 changes: 2 additions & 0 deletions extensions/git/src/api/git.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,8 @@ export interface DiffChange extends Change {
readonly deletions: number;
}

export type RepositoryKind = 'repository' | 'submodule' | 'worktree';

export interface RepositoryState {
readonly HEAD: Branch | undefined;
readonly refs: Ref[];
Expand Down
4 changes: 2 additions & 2 deletions extensions/git/src/repository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import picomatch from 'picomatch';
import { CancellationError, CancellationToken, CancellationTokenSource, Command, commands, Disposable, Event, EventEmitter, ExcludeSettingOptions, FileDecoration, FileType, l10n, LogLevel, LogOutputChannel, Memento, ProgressLocation, ProgressOptions, QuickDiffProvider, RelativePattern, scm, SourceControl, SourceControlInputBox, SourceControlInputBoxValidation, SourceControlInputBoxValidationType, SourceControlResourceDecorations, SourceControlResourceGroup, SourceControlResourceState, TabInputNotebookDiff, TabInputTextDiff, TabInputTextMultiDiff, ThemeColor, ThemeIcon, Uri, window, workspace, WorkspaceEdit } from 'vscode';
import { ActionButton } from './actionButton';
import { ApiRepository } from './api/api1';
import { Branch, BranchQuery, Change, CommitOptions, DiffChange, FetchOptions, ForcePushMode, GitErrorCodes, LogOptions, Ref, RefType, Remote, Status } from './api/git';
import { Branch, BranchQuery, Change, CommitOptions, DiffChange, FetchOptions, ForcePushMode, GitErrorCodes, LogOptions, Ref, RefType, Remote, RepositoryKind, Status } from './api/git';
import { AutoFetcher } from './autofetch';
import { GitBranchProtectionProvider, IBranchProtectionProviderRegistry } from './branchProtection';
import { debounce, memoize, sequentialize, throttle } from './decorators';
Expand Down Expand Up @@ -870,7 +870,7 @@ export class Repository implements Disposable {
return this.repository.dotGit;
}

get kind(): 'repository' | 'submodule' | 'worktree' {
get kind(): RepositoryKind {
return this.repository.kind;
}

Expand Down
32 changes: 11 additions & 21 deletions src/vs/base/browser/domStylesheets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/

import { DisposableStore, toDisposable, IDisposable } from '../common/lifecycle.js';
import { DisposableStore, toDisposable, IDisposable, Disposable } from '../common/lifecycle.js';
import { autorun, IObservable } from '../common/observable.js';
import { isFirefox } from './browser.js';
import { getWindows, sharedMutationObserver } from './dom.js';
Expand All @@ -15,35 +15,27 @@ export function isGlobalStylesheet(node: Node): boolean {
return globalStylesheets.has(node as HTMLStyleElement);
}

/**
* A version of createStyleSheet which has a unified API to initialize/set the style content.
*/
export function createStyleSheet2(): WrappedStyleElement {
return new WrappedStyleElement();
}

class WrappedStyleElement {
class WrappedStyleElement extends Disposable {
private _currentCssStyle = '';
private _styleSheet: HTMLStyleElement | undefined = undefined;

public setStyle(cssStyle: string): void {
setStyle(cssStyle: string): void {
if (cssStyle === this._currentCssStyle) {
return;
}
this._currentCssStyle = cssStyle;

if (!this._styleSheet) {
this._styleSheet = createStyleSheet(mainWindow.document.head, (s) => s.textContent = cssStyle);
this._styleSheet = createStyleSheet(mainWindow.document.head, s => s.textContent = cssStyle, this._store);
} else {
this._styleSheet.textContent = cssStyle;
}
}

public dispose(): void {
if (this._styleSheet) {
this._styleSheet.remove();
this._styleSheet = undefined;
}
override dispose(): void {
super.dispose();

this._styleSheet = undefined;
}
}

Expand Down Expand Up @@ -121,12 +113,10 @@ function getSharedStyleSheet(): HTMLStyleElement {

function getDynamicStyleSheetRules(style: HTMLStyleElement) {
if (style?.sheet?.rules) {
// Chrome, IE
return style.sheet.rules;
return style.sheet.rules; // Chrome, IE
}
if (style?.sheet?.cssRules) {
// FF
return style.sheet.cssRules;
return style.sheet.cssRules; // FF
}
return [];
}
Expand Down Expand Up @@ -174,7 +164,7 @@ function isCSSStyleRule(rule: CSSRule): rule is CSSStyleRule {

export function createStyleSheetFromObservable(css: IObservable<string>): IDisposable {
const store = new DisposableStore();
const w = store.add(createStyleSheet2());
const w = store.add(new WrappedStyleElement());
store.add(autorun(reader => {
w.setStyle(css.read(reader));
}));
Expand Down
25 changes: 24 additions & 1 deletion src/vs/editor/common/languages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -753,6 +753,18 @@ export enum InlineCompletionTriggerKind {
Explicit = 1,
}

/**
* Arbitrary data that the provider can pass when firing {@link InlineCompletionsProvider.onDidChangeInlineCompletions}.
* This data is passed back to the provider in {@link InlineCompletionContext.changeHint}.
*/
export interface IInlineCompletionChangeHint {
/**
* Arbitrary data that the provider can use to identify what triggered the change.
* This data must be JSON serializable.
*/
readonly data?: unknown;
}

export interface InlineCompletionContext {

/**
Expand All @@ -775,6 +787,12 @@ export interface InlineCompletionContext {
readonly includeInlineCompletions: boolean;
readonly requestIssuedDateTime: number;
readonly earliestShownDateTime: number;

/**
* The change hint that was passed to {@link InlineCompletionsProvider.onDidChangeInlineCompletions}.
* Only set if this request was triggered by such an event.
*/
readonly changeHint?: IInlineCompletionChangeHint;
}

export interface IInlineCompletionModelInfo {
Expand Down Expand Up @@ -946,7 +964,12 @@ export interface InlineCompletionsProvider<T extends InlineCompletions = InlineC
*/
disposeInlineCompletions(completions: T, reason: InlineCompletionsDisposeReason): void;

onDidChangeInlineCompletions?: Event<void>;
/**
* Fired when the provider wants to trigger a new completion request.
* The event can pass a {@link IInlineCompletionChangeHint} which will be
* included in the {@link InlineCompletionContext} of the subsequent request.
*/
onDidChangeInlineCompletions?: Event<IInlineCompletionChangeHint | void>;

/**
* Only used for {@link yieldsToGroupIds}.
Expand Down
Loading
Loading