Skip to content

Commit

Permalink
Prepare 2.0.2 (#6)
Browse files Browse the repository at this point in the history
* Fix infinite hover load on non-flag string literals

* Update CHANGELOG.md

* Prepare 2.0.2
  • Loading branch information
Arnold Trakhtenberg authored Oct 4, 2018
1 parent 3d0a79a commit 2a3bacd
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 45 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@

All notable changes to the "launchdarkly" extension will be documented in this file.

## [2.0.2] - 2018-10-04

### Fixed

- Fixed a bug causing hovers on non-flag string literals to indefinitely display loading text

## [2.0.1] - 2018-09-28

### Fixed
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "launchdarkly",
"displayName": "LaunchDarkly",
"description": "View LaunchDarkly feature flags in your editor.",
"version": "2.0.1",
"version": "2.0.2",
"publisher": "launchdarkly",
"engines": {
"vscode": "^1.18.0"
Expand Down
87 changes: 43 additions & 44 deletions src/flags.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,26 +107,28 @@ export class LDFlagManager implements IFlagManager {
let config = this.config(settings);
if (settings.sdkKey) {
this.updateProcessor = StreamProcessor(settings.sdkKey, config, Requestor(settings.sdkKey, config));
this.start()
this.start();
} else {
vscode.window.showWarningMessage('[LaunchDarkly] sdkKey is not set. LaunchDarkly language support is unavailable.');
vscode.window.showWarningMessage(
'[LaunchDarkly] sdkKey is not set. LaunchDarkly language support is unavailable.',
);
}

}

start() {
this.updateProcessor && this.updateProcessor.start(function (err) {
if (err) {
console.log(err);
let errMsg = `[LaunchDarkly] Unexpected error retrieving flags.${this.settings.baseUri != DEFAULT_BASE_URI ||
this.updateProcessor &&
this.updateProcessor.start(function(err) {
if (err) {
console.log(err);
let errMsg = `[LaunchDarkly] Unexpected error retrieving flags.${this.settings.baseUri != DEFAULT_BASE_URI ||
this.settings.streamUri != DEFAULT_STREAM_URI
? ' Please make sure your configured base and stream URIs are correct'
: ''}`;
vscode.window.showErrorMessage(errMsg);
} else {
process.nextTick(function () { });
}
});
? ' Please make sure your configured base and stream URIs are correct'
: ''}`;
vscode.window.showErrorMessage(errMsg);
} else {
process.nextTick(function() {});
}
});
}

reload(newSettings: IConfiguration) {
Expand All @@ -135,14 +137,10 @@ export class LDFlagManager implements IFlagManager {
this.settings.baseUri !== newSettings.baseUri ||
this.settings.streamUri !== newSettings.streamUri
) {
let config = this.config(newSettings)
let config = this.config(newSettings);
this.updateProcessor && this.updateProcessor.stop();
this.updateProcessor = StreamProcessor(
newSettings.sdkKey,
config,
Requestor(newSettings.sdkKey, config),
);
this.start()
this.updateProcessor = StreamProcessor(newSettings.sdkKey, config, Requestor(newSettings.sdkKey, config));
this.start();
}
this.settings = newSettings;
}
Expand All @@ -163,26 +161,21 @@ export class LDFlagManager implements IFlagManager {
}

registerProviders(ctx: vscode.ExtensionContext, settings: IConfiguration) {
if (settings.enableAutocomplete) {
ctx.subscriptions.push(
vscode.languages.registerCompletionItemProvider(
LD_MODE,
new this.LaunchDarklyCompletionItemProvider(),
"'",
'"',
),
);
}
if (settings.enableHover) {
ctx.subscriptions.push(
vscode.languages.registerHoverProvider(LD_MODE, new this.LaunchDarklyHoverProvider()),
);
}
ctx.subscriptions.push(
vscode.languages.registerCompletionItemProvider(LD_MODE, new this.LaunchDarklyCompletionItemProvider(), "'", '"'),
);

ctx.subscriptions.push(vscode.languages.registerHoverProvider(LD_MODE, new this.LaunchDarklyHoverProvider()));

ctx.subscriptions.push(vscode.commands.registerTextEditorCommand('extension.openInLaunchDarkly', editor => {
let flagKey = editor.document.getText(editor.document.getWordRangeAtPosition(editor.selection.anchor, FLAG_KEY_REGEX));
ctx.subscriptions.push(
vscode.commands.registerTextEditorCommand('extension.openInLaunchDarkly', editor => {
let flagKey = editor.document.getText(
editor.document.getWordRangeAtPosition(editor.selection.anchor, FLAG_KEY_REGEX),
);
if (!flagKey) {
vscode.window.showErrorMessage('[LaunchDarkly] Error retrieving flag (current cursor position is not a feature flag).');
vscode.window.showErrorMessage(
'[LaunchDarkly] Error retrieving flag (current cursor position is not a feature flag).',
);
return;
}

Expand All @@ -204,22 +197,28 @@ export class LDFlagManager implements IFlagManager {
opn(url.resolve(settings.baseUri, flag.environments[settings.env]._site.href));
}
});
}));
}),
);
}

get LaunchDarklyHoverProvider() {
const settings = this.settings;
const store = this.store;
return class LaunchDarklyHoverProvider implements vscode.HoverProvider {
public provideHover(document: vscode.TextDocument, position: vscode.Position): Thenable<vscode.Hover> {
return new Promise(resolve => {
return new Promise((resolve, reject) => {
settings.enableHover
? store.all(DATA_KIND, flags => {
let candidate = document.getText(document.getWordRangeAtPosition(position, FLAG_KEY_REGEX));
let flag = generateHoverString(flags[candidate] || flags[kebabCase(candidate)]);
flag ? resolve(new vscode.Hover(flag)) : resolve();
let flag = flags[candidate] || flags[kebabCase(candidate)];
if (flag) {
let hover = generateHoverString(flag);
resolve(new vscode.Hover(hover));
return;
}
reject();
})
: resolve();
: reject();
});
}
};
Expand Down

0 comments on commit 2a3bacd

Please sign in to comment.