Explorar el Código

Fixes issue with settings editor not refreshing after being hidden

Adds the gitlens icon to settings editor and welcome page
main
Eric Amodio hace 6 años
padre
commit
78aa0a4994
Se han modificado 3 ficheros con 69 adiciones y 65 borrados
  1. +25
    -19
      package-lock.json
  2. +2
    -2
      package.json
  3. +42
    -44
      src/webviews/webviewEditor.ts

+ 25
- 19
package-lock.json Ver fichero

@ -1127,7 +1127,7 @@
},
"browserify-aes": {
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/browserify-aes/-/browserify-aes-1.2.0.tgz",
"resolved": "http://registry.npmjs.org/browserify-aes/-/browserify-aes-1.2.0.tgz",
"integrity": "sha512-+7CHXqGuspUn/Sl5aO7Ea0xWGAtETPXNSAjHo48JfLdPWcMng33Xe4znFvQweqc/uzk5zSOI3H52CYnjCfb5hA==",
"dev": true,
"requires": {
@ -1164,7 +1164,7 @@
},
"browserify-rsa": {
"version": "4.0.1",
"resolved": "https://registry.npmjs.org/browserify-rsa/-/browserify-rsa-4.0.1.tgz",
"resolved": "http://registry.npmjs.org/browserify-rsa/-/browserify-rsa-4.0.1.tgz",
"integrity": "sha1-IeCr+vbyApzy+vsTNWenAdQTVSQ=",
"dev": true,
"requires": {
@ -2052,7 +2052,7 @@
},
"create-hash": {
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/create-hash/-/create-hash-1.2.0.tgz",
"resolved": "http://registry.npmjs.org/create-hash/-/create-hash-1.2.0.tgz",
"integrity": "sha512-z00bCGNHDG8mHAkP7CtT1qVu+bFQUPjYq/4Iv3C3kWjTFV10zIjfSoeqXo9Asws8gwSHDGj/hl2u4OGIjapeCg==",
"dev": true,
"requires": {
@ -2065,7 +2065,7 @@
},
"create-hmac": {
"version": "1.1.7",
"resolved": "https://registry.npmjs.org/create-hmac/-/create-hmac-1.1.7.tgz",
"resolved": "http://registry.npmjs.org/create-hmac/-/create-hmac-1.1.7.tgz",
"integrity": "sha512-MJG9liiZ+ogc4TzUwuvbER1JRdgvUFSB5+VR/g5h82fGaIRWMWddtKBHi7/sVhfjQZ6SehlyhvQYrcYkaUIpLg==",
"dev": true,
"requires": {
@ -2589,7 +2589,7 @@
},
"diffie-hellman": {
"version": "5.0.3",
"resolved": "https://registry.npmjs.org/diffie-hellman/-/diffie-hellman-5.0.3.tgz",
"resolved": "http://registry.npmjs.org/diffie-hellman/-/diffie-hellman-5.0.3.tgz",
"integrity": "sha512-kqag/Nl+f3GwyK25fhUMYj81BUOrZ9IuJsjIcDE5icNM9FJHAVm3VcUDxdLPoQtTuUylWm6ZIknYJwwaPxsUzg==",
"dev": true,
"requires": {
@ -3491,7 +3491,7 @@
},
"readable-stream": {
"version": "2.3.6",
"resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.6.tgz",
"resolved": "http://registry.npmjs.org/readable-stream/-/readable-stream-2.3.6.tgz",
"integrity": "sha512-tQtKA9WIAhBF3+VLAseyMqZeBjW0AHJoxOtYqSUZNJxauErmLbVm2FW1y+J/YA9dUrAC39ITejlZWhVIwawkKw==",
"dev": true,
"requires": {
@ -3580,7 +3580,7 @@
},
"readable-stream": {
"version": "2.3.6",
"resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.6.tgz",
"resolved": "http://registry.npmjs.org/readable-stream/-/readable-stream-2.3.6.tgz",
"integrity": "sha512-tQtKA9WIAhBF3+VLAseyMqZeBjW0AHJoxOtYqSUZNJxauErmLbVm2FW1y+J/YA9dUrAC39ITejlZWhVIwawkKw==",
"dev": true,
"requires": {
@ -6944,7 +6944,7 @@
},
"readable-stream": {
"version": "2.3.6",
"resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.6.tgz",
"resolved": "http://registry.npmjs.org/readable-stream/-/readable-stream-2.3.6.tgz",
"integrity": "sha512-tQtKA9WIAhBF3+VLAseyMqZeBjW0AHJoxOtYqSUZNJxauErmLbVm2FW1y+J/YA9dUrAC39ITejlZWhVIwawkKw==",
"dev": true,
"requires": {
@ -7351,7 +7351,7 @@
},
"readable-stream": {
"version": "2.3.6",
"resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.6.tgz",
"resolved": "http://registry.npmjs.org/readable-stream/-/readable-stream-2.3.6.tgz",
"integrity": "sha512-tQtKA9WIAhBF3+VLAseyMqZeBjW0AHJoxOtYqSUZNJxauErmLbVm2FW1y+J/YA9dUrAC39ITejlZWhVIwawkKw==",
"dev": true,
"requires": {
@ -7825,7 +7825,7 @@
},
"readable-stream": {
"version": "2.3.6",
"resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.6.tgz",
"resolved": "http://registry.npmjs.org/readable-stream/-/readable-stream-2.3.6.tgz",
"integrity": "sha512-tQtKA9WIAhBF3+VLAseyMqZeBjW0AHJoxOtYqSUZNJxauErmLbVm2FW1y+J/YA9dUrAC39ITejlZWhVIwawkKw==",
"dev": true,
"requires": {
@ -7860,7 +7860,7 @@
},
"parse-asn1": {
"version": "5.1.1",
"resolved": "https://registry.npmjs.org/parse-asn1/-/parse-asn1-5.1.1.tgz",
"resolved": "http://registry.npmjs.org/parse-asn1/-/parse-asn1-5.1.1.tgz",
"integrity": "sha512-KPx7flKXg775zZpnp9SxJlz00gTd4BmJ2yJufSc44gMCRrRQ7NSzAcSJQfifuOLgW6bEi+ftrALtsgALeB2Adw==",
"dev": true,
"requires": {
@ -8728,7 +8728,7 @@
},
"public-encrypt": {
"version": "4.0.2",
"resolved": "https://registry.npmjs.org/public-encrypt/-/public-encrypt-4.0.2.tgz",
"resolved": "http://registry.npmjs.org/public-encrypt/-/public-encrypt-4.0.2.tgz",
"integrity": "sha512-4kJ5Esocg8X3h8YgJsKAuoesBgB7mqH3eowiDzMUPKiRDDE7E/BqqZD1hnTByIaAFiwAw246YEltSq7tdrOH0Q==",
"dev": true,
"requires": {
@ -9460,7 +9460,7 @@
},
"sha.js": {
"version": "2.4.11",
"resolved": "https://registry.npmjs.org/sha.js/-/sha.js-2.4.11.tgz",
"resolved": "http://registry.npmjs.org/sha.js/-/sha.js-2.4.11.tgz",
"integrity": "sha512-QMEp5B7cftE7APOjk5Y6xgrbWu+WkLVQwk8JNjZ8nKRciZaByEW6MubieAiToS7+dwvrjGhH8jRXz3MVd0AYqQ==",
"dev": true,
"requires": {
@ -9932,7 +9932,7 @@
},
"readable-stream": {
"version": "2.3.6",
"resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.6.tgz",
"resolved": "http://registry.npmjs.org/readable-stream/-/readable-stream-2.3.6.tgz",
"integrity": "sha512-tQtKA9WIAhBF3+VLAseyMqZeBjW0AHJoxOtYqSUZNJxauErmLbVm2FW1y+J/YA9dUrAC39ITejlZWhVIwawkKw==",
"dev": true,
"requires": {
@ -10039,7 +10039,7 @@
},
"readable-stream": {
"version": "2.3.6",
"resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.6.tgz",
"resolved": "http://registry.npmjs.org/readable-stream/-/readable-stream-2.3.6.tgz",
"integrity": "sha512-tQtKA9WIAhBF3+VLAseyMqZeBjW0AHJoxOtYqSUZNJxauErmLbVm2FW1y+J/YA9dUrAC39ITejlZWhVIwawkKw==",
"dev": true,
"requires": {
@ -11349,9 +11349,9 @@
}
},
"webpack": {
"version": "4.18.0",
"resolved": "https://registry.npmjs.org/webpack/-/webpack-4.18.0.tgz",
"integrity": "sha512-XOGIV1FuGSisuX0gJwoANpR0+rUnlDWf2dadNfdT8ftaM8QzIMsJin2vK9XaYuhsji321C6dnCV4bxbIwq9jrg==",
"version": "4.19.0",
"resolved": "https://registry.npmjs.org/webpack/-/webpack-4.19.0.tgz",
"integrity": "sha512-Ak3mMGtA8F1ar4ZP6VCLiICNIPoillROGYstnEd+LzI5Tkvz0qTITeTMcAFjxyYsaxu98F97yrCWdcxRUMPAYw==",
"dev": true,
"requires": {
"@webassemblyjs/ast": "1.7.6",
@ -11374,7 +11374,7 @@
"neo-async": "^2.5.0",
"node-libs-browser": "^2.0.0",
"schema-utils": "^0.4.4",
"tapable": "^1.0.0",
"tapable": "^1.1.0",
"uglifyjs-webpack-plugin": "^1.2.4",
"watchpack": "^1.5.0",
"webpack-sources": "^1.2.0"
@ -11389,6 +11389,12 @@
"ajv": "^6.1.0",
"ajv-keywords": "^3.1.0"
}
},
"tapable": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/tapable/-/tapable-1.1.0.tgz",
"integrity": "sha512-IlqtmLVaZA2qab8epUXbVWRn3aB1imbDMJtjB3nu4X0NqPkcY/JH9ZtCBWKHWPxs8Svi9tyo8w2dBoi07qZbBA==",
"dev": true
}
}
},

+ 2
- 2
package.json Ver fichero

@ -18,7 +18,7 @@
"url": "https://github.com/eamodio/vscode-gitlens.git"
},
"engines": {
"vscode": "^1.25.0"
"vscode": "^1.27.0"
},
"main": "./dist/extension",
"icon": "images/gitlens-icon.png",
@ -3691,7 +3691,7 @@
"ts-loader": "5.1.0",
"typescript": "3.0.3",
"vscode": "1.1.21",
"webpack": "4.18.0",
"webpack": "4.19.0",
"webpack-cli": "3.1.0",
"webpack-deep-scope-plugin": "1.6.0"
}

+ 42
- 44
src/webviews/webviewEditor.ts Ver fichero

@ -49,24 +49,15 @@ export abstract class WebviewEditor implements Disposable {
this._panel = undefined;
}
private _invalidateOnVisible: 'all' | 'config' | undefined;
private onViewStateChanged(e: WebviewPanelOnDidChangeViewStateEvent) {
Logger.log('WebviewEditor.onViewStateChanged', e.webviewPanel.visible);
// HACK: Because messages aren't sent to the webview when hidden, we need make sure it is up-to-date
if (this._invalidateOnVisible && e.webviewPanel.visible) {
const invalidates = this._invalidateOnVisible;
this._invalidateOnVisible = undefined;
switch (invalidates) {
case 'config':
this.postUpdatedConfiguration();
break;
default:
void this.show();
break;
}
Logger.log(
'WebviewEditor.onViewStateChanged',
`active=${e.webviewPanel.active}, visible=${e.webviewPanel.visible}`
);
// Anytime the webview becomes active, make sure it has the most up-to-date config
if (e.webviewPanel.active) {
this.postUpdatedConfiguration();
}
}
@ -104,21 +95,13 @@ export abstract class WebviewEditor implements Disposable {
}
async show(): Promise<void> {
let html = (await this.getHtml()).replace(
/{{root}}/g,
Uri.file(Container.context.asAbsolutePath('.'))
.with({ scheme: 'vscode-resource' })
.toString(true)
);
if (html.includes("'{{bootstrap}}'")) {
html = html.replace("'{{bootstrap}}'", JSON.stringify(this.getBootstrap()));
}
const html = await this.getHtml();
if (this._panel === undefined) {
this._panel = window.createWebviewPanel(
this.id,
this.title,
ViewColumn.Active, // { viewColumn: ViewColumn.Active, preserveFocus: false }
{ viewColumn: ViewColumn.Active, preserveFocus: false },
{
retainContextWhenHidden: true,
enableFindWidget: true,
@ -127,6 +110,7 @@ export abstract class WebviewEditor implements Disposable {
}
);
this._panel.iconPath = Uri.file(Container.context.asAbsolutePath('images/gitlens-icon.png'));
this._disposablePanel = Disposable.from(
this._panel,
this._panel.onDidDispose(this.onPanelDisposed, this),
@ -137,14 +121,19 @@ export abstract class WebviewEditor implements Disposable {
this._panel.webview.html = html;
}
else {
// Reset the html to get the webview to reload
this._panel.webview.html = '';
this._panel.webview.html = html;
this._panel.reveal(ViewColumn.Active); // , false);
this._panel.reveal(ViewColumn.Active, false);
}
}
private _html: string | undefined;
private async getHtml(): Promise<string> {
let content;
// When we are debugging avoid any caching so that we can change the html and have it update without reloading
if (Logger.isDebugging) {
return new Promise<string>((resolve, reject) => {
content = await new Promise<string>((resolve, reject) => {
fs.readFile(Container.context.asAbsolutePath(this.filename), 'utf8', (err, data) => {
if (err) {
reject(err);
@ -155,29 +144,38 @@ export abstract class WebviewEditor implements Disposable {
});
});
}
else {
if (this._html !== undefined) return this._html;
const doc = await workspace.openTextDocument(Container.context.asAbsolutePath(this.filename));
content = doc.getText();
}
this._html = content.replace(
/{{root}}/g,
Uri.file(Container.context.asAbsolutePath('.'))
.with({ scheme: 'vscode-resource' })
.toString()
);
if (this._html.includes("'{{bootstrap}}'")) {
this._html = this._html.replace("'{{bootstrap}}'", JSON.stringify(this.getBootstrap()));
}
const doc = await workspace.openTextDocument(Container.context.asAbsolutePath(this.filename));
return doc.getText();
return this._html;
}
private postMessage(message: Message, invalidates: 'all' | 'config' = 'all') {
private postMessage(message: Message) {
if (this._panel === undefined) return false;
const result = this._panel!.webview.postMessage(message);
if (!result && this._invalidateOnVisible !== 'all') {
this._invalidateOnVisible = invalidates;
}
return result;
return this._panel!.webview.postMessage(message);
}
private postUpdatedConfiguration() {
// Make sure to get the raw config, not from the container which has the modes mixed in
return this.postMessage(
{
type: 'settingsChanged',
config: configuration.get<Config>()
} as SettingsChangedMessage,
'config'
);
return this.postMessage({
type: 'settingsChanged',
config: configuration.get<Config>()
} as SettingsChangedMessage);
}
}

Cargando…
Cancelar
Guardar