Skip to content

Commit

Permalink
Rebase against the upstream 728b9a0
Browse files Browse the repository at this point in the history
vscode-upstream-sha1: 728b9a0
  • Loading branch information
Eclipse Che Sync committed Jul 31, 2023
2 parents 87aee69 + 728b9a0 commit 2d584ff
Show file tree
Hide file tree
Showing 13 changed files with 152 additions and 57 deletions.
25 changes: 21 additions & 4 deletions code/cli/src/auth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ impl StoredCredential {

struct StorageWithLastRead {
storage: Box<dyn StorageImplementation>,
fallback_storage: Option<FileStorage>,
last_read: Cell<Result<Option<StoredCredential>, WrappedError>>,
}

Expand Down Expand Up @@ -392,14 +393,18 @@ impl Auth {
let mut keyring_storage = ThreadKeyringStorage::default();
let mut file_storage = FileStorage(PersistedState::new(self.file_storage_path.clone()));

let keyring_storage_result = match std::env::var("VSCODE_CLI_USE_FILE_KEYCHAIN") {
Ok(_) => Err(wrap("", "user prefers file storage").into()),
_ => keyring_storage.read(),
let native_storage_result = if std::env::var("VSCODE_CLI_USE_FILE_KEYCHAIN").is_ok()
|| self.file_storage_path.exists()
{
Err(wrap("", "user prefers file storage").into())
} else {
keyring_storage.read()
};

let mut storage = match keyring_storage_result {
let mut storage = match native_storage_result {
Ok(v) => StorageWithLastRead {
last_read: Cell::new(Ok(v)),
fallback_storage: Some(file_storage),
storage: Box::new(keyring_storage),
},
Err(e) => {
Expand All @@ -410,6 +415,7 @@ impl Auth {
.read()
.map_err(|e| wrap(e, "could not read from file storage")),
),
fallback_storage: None,
storage: Box::new(file_storage),
}
}
Expand Down Expand Up @@ -531,7 +537,18 @@ impl Auth {
"Failed to update keyring with new credentials: {}",
e
);

if let Some(fb) = storage.fallback_storage.take() {
storage.storage = Box::new(fb);
match storage.storage.store(creds.clone()) {
Err(e) => {
warning!(self.log, "Also failed to update fallback storage: {}", e)
}
Ok(_) => debug!(self.log, "Updated fallback storage successfully"),
}
}
}

storage.last_read.set(Ok(Some(creds)));
})
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ export function validateLink(urlList: string): { isValid: boolean; cleanedUrlLis
}
const splitUrlList = trimmedUrlList.split(' ').filter(item => item !== ''); //split on spaces and remove empty strings
if (uri) {
isValid = splitUrlList.length === 1 && !splitUrlList[0].includes('\n') && externalUriSchemes.includes(vscode.Uri.parse(splitUrlList[0]).scheme);
isValid = splitUrlList.length === 1 && !splitUrlList[0].includes('\n') && externalUriSchemes.includes(vscode.Uri.parse(splitUrlList[0]).scheme) && !!vscode.Uri.parse(splitUrlList[0]).authority;
}
return { isValid, cleanedUrlList: splitUrlList[0] };
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,9 @@ export async function createEditAddingLinksForUriList(

export function checkSmartPaste(document: SkinnyTextDocument, selectedRange: vscode.Range): SmartPaste {
const SmartPaste: SmartPaste = { pasteAsMarkdownLink: true, updateTitle: false };
if (selectedRange.isEmpty || /^[\s\n]*$/.test(document.getText(selectedRange))) {
return { pasteAsMarkdownLink: false, updateTitle: false };
}
for (const regex of smartPasteRegexes) {
const matches = [...document.getText().matchAll(regex.regex)];
for (const match of matches) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,11 @@ suite('createEditAddingLinksForUriList', () => {
const isLink = validateLink('https://www.microsoft.com/ \r\nhttps://www.microsoft.com/\r\nhttps://www.microsoft.com/\r\n hello \r\nhttps://www.microsoft.com/').isValid;
assert.strictEqual(isLink, false);
});

test('Markdown pasting should not occur for just a valid uri scheme', () => {
const isLink = validateLink('https://').isValid;
assert.strictEqual(isLink, false);
});
});

suite('appendToLinkSnippet', () => {
Expand Down Expand Up @@ -148,11 +153,24 @@ suite('createEditAddingLinksForUriList', () => {
};

test('Should evaluate pasteAsMarkdownLink as true for selected plain text', () => {
const range = new vscode.Range(0, 5, 0, 5);
const range = new vscode.Range(0, 0, 0, 12);
const smartPaste = checkSmartPaste(skinnyDocument, range);
assert.strictEqual(smartPaste.pasteAsMarkdownLink, true);
});

test('Should evaluate pasteAsMarkdownLink as false for no selection', () => {
const range = new vscode.Range(0, 0, 0, 0);
const smartPaste = checkSmartPaste(skinnyDocument, range);
assert.strictEqual(smartPaste.pasteAsMarkdownLink, false);
});

test('Should evaluate pasteAsMarkdownLink as false for selected whitespace and new lines', () => {
skinnyDocument.getText = function () { return ' \r\n\r\n'; };
const range = new vscode.Range(0, 0, 0, 7);
const smartPaste = checkSmartPaste(skinnyDocument, range);
assert.strictEqual(smartPaste.pasteAsMarkdownLink, false);
});

test('Should evaluate pasteAsMarkdownLink as false for pasting within a backtick code block', () => {
skinnyDocument.getText = function () { return '```\r\n\r\n```'; };
const range = new vscode.Range(0, 5, 0, 5);
Expand Down
2 changes: 1 addition & 1 deletion code/extensions/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"license": "MIT",
"description": "Dependencies shared by all extensions",
"dependencies": {
"typescript": "5.1.6"
"typescript": "^5.2.0-dev.20230731"
},
"scripts": {
"postinstall": "node ./postinstall.mjs"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,7 @@ export default class FileConfigurationManager extends Disposable {
allowIncompleteCompletions: true,
displayPartsForJSDoc: true,
disableLineTextInReferences: true,
interactiveInlayHints: true,
...getInlayHintsPreferences(config),
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { DocumentSelector } from '../configuration/documentSelector';
import { LanguageDescription } from '../configuration/languageDescription';
import { API } from '../tsServer/api';
import type * as Proto from '../tsServer/protocol/protocol';
import { Position } from '../typeConverters';
import { Location, Position } from '../typeConverters';
import { ClientCapability, ITypeScriptServiceClient } from '../typescriptService';
import { Disposable } from '../utils/dispose';
import FileConfigurationManager, { InlayHintSettingNames, getInlayHintsPreferences } from './fileConfigurationManager';
Expand Down Expand Up @@ -77,14 +77,28 @@ class TypeScriptInlayHintsProvider extends Disposable implements vscode.InlayHin
return response.body.map(hint => {
const result = new vscode.InlayHint(
Position.fromLocation(hint.position),
hint.text,
this.convertInlayHintText(model.uri, hint),
hint.kind && fromProtocolInlayHintKind(hint.kind)
);
result.paddingLeft = hint.whitespaceBefore;
result.paddingRight = hint.whitespaceAfter;
return result;
});
}

private convertInlayHintText(resource: vscode.Uri, tsHint: Proto.InlayHintItem): string | vscode.InlayHintLabelPart[] {
if (typeof tsHint.text === 'string') {
return tsHint.text;
}

return tsHint.text.map((part): vscode.InlayHintLabelPart => {
const out = new vscode.InlayHintLabelPart(part.text);
if (part.span) {
out.location = Location.fromTextSpan(resource, part.span);
}
return out;
});
}
}

function fromProtocolInlayHintKind(kind: Proto.InlayHintKind): vscode.InlayHintKind | undefined {
Expand Down
8 changes: 4 additions & 4 deletions code/extensions/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -228,10 +228,10 @@ to-regex-range@^5.0.1:
dependencies:
is-number "^7.0.0"

typescript@5.1.6:
version "5.1.6"
resolved "https://registry.yarnpkg.com/typescript/-/typescript-5.1.6.tgz#02f8ac202b6dad2c0dd5e0913745b47a37998274"
integrity sha512-zaWCozRZ6DLEWAWFrVDz1H6FVXzUSfTy5FUMWsQlU8Ym5JP9eO4xkTIROFCQvhQf61z6O/G6ugw3SgAnvvm+HA==
typescript@^5.2.0-dev.20230731:
version "5.2.0-dev.20230731"
resolved "https://registry.yarnpkg.com/typescript/-/typescript-5.2.0-dev.20230731.tgz#a72083c07043568ab856dd8ca0d8f3a708c3e3a6"
integrity sha512-RJVLgnDgu67ZrohYy0aBea+5TICfRod36+24zw0bR/KJDQJO9mlIjTC0k+/PKw87fXP5JuUHqepEk15PvFya7A==

vscode-grammar-updater@^1.1.0:
version "1.1.0"
Expand Down
4 changes: 2 additions & 2 deletions code/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "che-code",
"version": "1.82.0",
"distro": "3278b6d258cb23d8d52820288c40fdba5e61ddd4",
"distro": "2a9b1552a828c44e6454db2848ba954f2497a6b3",
"author": {
"name": "Microsoft Corporation"
},
Expand Down Expand Up @@ -214,7 +214,7 @@
"ts-loader": "^9.4.2",
"ts-node": "^10.9.1",
"tsec": "0.2.7",
"typescript": "^5.2.0-dev.20230718",
"typescript": "^5.2.0-dev.20230731",
"typescript-formatter": "7.1.0",
"underscore": "^1.12.1",
"util": "^0.12.4",
Expand Down
70 changes: 33 additions & 37 deletions code/src/vs/workbench/api/browser/mainThreadTerminalService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,10 @@ import { withNullAsUndefined } from 'vs/base/common/types';
import { OperatingSystem, OS } from 'vs/base/common/platform';
import { TerminalEditorLocationOptions } from 'vscode';
import { Promises } from 'vs/base/common/async';
import { CancellationToken } from 'vs/base/common/cancellation';
import { ITerminalCommand } from 'vs/platform/terminal/common/capabilities/capabilities';
import { TerminalQuickFixType } from 'vs/workbench/api/common/extHostTypes';
import { ISerializableEnvironmentDescriptionMap, ISerializableEnvironmentVariableCollection } from 'vs/platform/terminal/common/environmentVariable';
import { ITerminalLinkProviderService } from 'vs/workbench/contrib/terminalContrib/links/browser/links';
import { ITerminalQuickFixService, ITerminalQuickFixOptions, ITerminalQuickFix } from 'vs/workbench/contrib/terminalContrib/quickFix/browser/quickFix';
import { ITerminalQuickFixService, ITerminalQuickFix } from 'vs/workbench/contrib/terminalContrib/quickFix/browser/quickFix';


@extHostNamedCustomer(MainContext.MainThreadTerminalService)
Expand Down Expand Up @@ -261,42 +259,40 @@ export class MainThreadTerminalService implements MainThreadTerminalServiceShape
}

public async $registerQuickFixProvider(id: string, extensionId: string): Promise<void> {
this._quickFixProviders.set(id, this._terminalQuickFixService.registerQuickFixProvider(id,
{
provideTerminalQuickFixes: async (terminalCommand: ITerminalCommand, lines: string[], option: ITerminalQuickFixOptions, token: CancellationToken) => {
if (token.isCancellationRequested) {
return;
}
if (option.outputMatcher?.length && option.outputMatcher.length > 40) {
option.outputMatcher.length = 40;
this._logService.warn('Cannot exceed output matcher length of 40');
}
const commandLineMatch = terminalCommand.command.match(option.commandLineMatcher);
if (!commandLineMatch) {
return;
}
const outputMatcher = option.outputMatcher;
let outputMatch;
if (outputMatcher) {
outputMatch = getOutputMatchForLines(lines, outputMatcher);
}
if (!outputMatch) {
return;
}
const matchResult = { commandLineMatch, outputMatch, commandLine: terminalCommand.command };

if (matchResult) {
const result = await this._proxy.$provideTerminalQuickFixes(id, matchResult, token);
if (result && Array.isArray(result)) {
return result.map(r => parseQuickFix(id, extensionId, r));
} else if (result) {
return parseQuickFix(id, extensionId, result);
}
}
this._quickFixProviders.set(id, this._terminalQuickFixService.registerQuickFixProvider(id, {
provideTerminalQuickFixes: async (terminalCommand, lines, options, token) => {
if (token.isCancellationRequested) {
return;
}
if (options.outputMatcher?.length && options.outputMatcher.length > 40) {
options.outputMatcher.length = 40;
this._logService.warn('Cannot exceed output matcher length of 40');
}
const commandLineMatch = terminalCommand.command.match(options.commandLineMatcher);
if (!commandLineMatch || !lines) {
return;
}
const outputMatcher = options.outputMatcher;
let outputMatch;
if (outputMatcher) {
outputMatch = getOutputMatchForLines(lines, outputMatcher);
}
if (!outputMatch) {
return;
}
})
);
const matchResult = { commandLineMatch, outputMatch, commandLine: terminalCommand.command };

if (matchResult) {
const result = await this._proxy.$provideTerminalQuickFixes(id, matchResult, token);
if (result && Array.isArray(result)) {
return result.map(r => parseQuickFix(id, extensionId, r));
} else if (result) {
return parseQuickFix(id, extensionId, result);
}
}
return;
}
}));
}

public $unregisterQuickFixProvider(id: string): void {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,10 @@ export class ExplorerView extends ViewPane implements IExplorerView {
}

isItemVisible(item: ExplorerItem): boolean {
// If filter is undefined it means the tree hasn't been rendered yet, so nothing is visible
if (!this.filter) {
return false;
}
return this.filter.filter(item, TreeVisibility.Visible);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -436,7 +436,7 @@ suite('NotebookTextModel', () => {
);
});

test('appending streaming outputs with compression', async function () {
test('appending streaming outputs with move cursor compression', async function () {

await withTestNotebook(
[
Expand Down Expand Up @@ -478,6 +478,48 @@ suite('NotebookTextModel', () => {
);
});

test('appending streaming outputs with carraige return compression', async function () {

await withTestNotebook(
[
['var a = 1;', 'javascript', CellKind.Code, [], {}],
],
(editor) => {
const textModel = editor.textModel;

textModel.applyEdits([
{
index: 0,
editType: CellEditType.Output,
append: true,
outputs: [{
outputId: 'append1',
outputs: [
{ mime: stdOutMime, data: valueBytesFromString('append 1') },
{ mime: stdOutMime, data: valueBytesFromString('\nappend 1') }]
}]
}], true, undefined, () => undefined, undefined, true);
const [output] = textModel.cells[0].outputs;
assert.strictEqual(output.versionId, 0, 'initial output version should be 0');

textModel.applyEdits([
{
editType: CellEditType.OutputItems,
append: true,
outputId: 'append1',
items: [{
mime: stdOutMime, data: valueBytesFromString('\rappend 2')
}]
}], true, undefined, () => undefined, undefined, true);
assert.strictEqual(output.versionId, 1, 'version should bump per append');

assert.strictEqual(output.outputs[0].data.toString(), 'append 1\nappend 2');
assert.strictEqual(output.appendedSinceVersion(0, stdOutMime), undefined,
'compressing outputs should clear out previous versioned output buffers');
}
);
});

test('appending multiple different mime streaming outputs', async function () {
await withTestNotebook(
[
Expand Down
8 changes: 4 additions & 4 deletions code/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -10087,10 +10087,10 @@ typescript@^4.7.4:
resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.8.4.tgz#c464abca159669597be5f96b8943500b238e60e6"
integrity sha512-QCh+85mCy+h0IGff8r5XWzOVSbBO+KfeYrMQh7NJ58QujwcE22u+NUSmUxqF+un70P9GXKxa2HCNiTTMJknyjQ==

typescript@^5.2.0-dev.20230718:
version "5.2.0-dev.20230718"
resolved "https://registry.yarnpkg.com/typescript/-/typescript-5.2.0-dev.20230718.tgz#8c60b2f6807b3f8b2db47980ee6c73dea1f45e42"
integrity sha512-ED1Vm+2UzdbtKui+0lVswEuAX94fQXeoghXyy/+aTNers8X/WB81r5sFg6nA4e43nVQ2MP/Qsa7/XJRFuHR+Cg==
typescript@^5.2.0-dev.20230731:
version "5.2.0-dev.20230731"
resolved "https://registry.yarnpkg.com/typescript/-/typescript-5.2.0-dev.20230731.tgz#a72083c07043568ab856dd8ca0d8f3a708c3e3a6"
integrity sha512-RJVLgnDgu67ZrohYy0aBea+5TICfRod36+24zw0bR/KJDQJO9mlIjTC0k+/PKw87fXP5JuUHqepEk15PvFya7A==

typical@^4.0.0:
version "4.0.0"
Expand Down

0 comments on commit 2d584ff

Please sign in to comment.