Skip to content

Commit 261d166

Browse files
committed
fix f6caa2c: actually get new style code, #2059
1 parent b367303 commit 261d166

File tree

3 files changed

+8
-8
lines changed

3 files changed

+8
-8
lines changed

src/background/style-manager/index.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -155,23 +155,23 @@ export function getByUrl(url, id, tabId, needsOvrs) {
155155
/**
156156
* @param {{}} [opts]
157157
* @param {number} [opts.id] - process and return only one style
158-
* @param {boolean} [opts.code] - include `code` and `sourceCode`
159-
* @param {boolean} [opts.sections] - include `sections`
158+
* @param {boolean} [opts.sections] - include `sections` stripped of `code`
159+
* @param {boolean} [opts.src] - include full `sections` if sectioned or `sourceCode` if UserCSS
160160
* @param {boolean} [opts.vars] - include `usercssData.vars`
161161
* @return {StyleObj[] | StyleObj}
162162
*/
163-
export function getCore({id, code, sections, size, vars} = {}) {
163+
export function getCore({id, sections, size, src, vars} = {}) {
164164
const res = [];
165165
for (let {style} of id ? [dataMap.get(id)] : dataMap.values()) {
166166
style = {...style};
167167
let tmp;
168168
if (size)
169169
style[k_size] = calcObjSize(style);
170-
if (!code && sections)
170+
if (sections)
171171
tmp = style.sections.map(sec => ({...sec, code: undefined}));
172-
if (!code || !sections)
172+
if (!src || !sections)
173173
style.sections = tmp;
174-
if (!code)
174+
if (!src)
175175
style.sourceCode = undefined;
176176
if (!vars && (tmp = style[UCD]) && tmp.vars)
177177
style[UCD] = {...tmp, vars: Object.keys(tmp.vars).length};

src/edit/on-msg-extension.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ async function handleExternalUpdate({style, reason, editorId}) {
3838
editor.updateMeta();
3939
return;
4040
}
41-
style = await API.styles.getCore({id: style.id, vars: true});
41+
style = await API.styles.getCore({id: style.id, src: true, vars: true});
4242
if (reason === 'config') {
4343
for (const key in editor.style)
4444
if (key !== 'sourceCode' && key !== 'sections' && !(key in style))

src/edit/source-editor.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ export default function SourceEditor() {
228228
if (!sameCode) {
229229
const si0 = draft && draft.si.cms[0];
230230
const cursor = !si0 && cm.getCursor();
231-
cm.setValue(newStyle.sourceCode);
231+
cm.setValue(style.sourceCode); // `style` is merged with `newStyle` by useSavedStyle
232232
if (si0) {
233233
editor.applyScrollInfo(cm, si0);
234234
} else {

0 commit comments

Comments
 (0)