瀏覽代碼

fixed regression when saving with the shortcut

Former-commit-id: 9c59fb60d3b800097bc7889f17f698bcc14d123c
Gildas 6 年之前
父節點
當前提交
7423302b54
共有 3 個文件被更改,包括 9 次插入6 次删除
  1. 6 3
      extension/core/content/content-main.js
  2. 1 1
      extension/ui/bg/ui-commands.js
  3. 2 2
      extension/ui/content/content-ui-main.js

+ 6 - 3
extension/core/content/content-main.js

@@ -66,8 +66,11 @@ this.singlefile.extension.core.content.main = this.singlefile.extension.core.con
 			options.updatedResources = singlefile.extension.core.content.updatedResources || {};
 			Object.keys(options.updatedResources).forEach(url => options.updatedResources[url].retrieved = false);
 			let selectionFound;
-			if (options.selected) {
-				selectionFound = await ui.markSelection();
+			if (options.selected || options.optionallySelected) {
+				selectionFound = await ui.markSelection(options.optionallySelected);
+			}
+			if (options.optionallySelected && selectionFound) {
+				options.selected = true;
 			}
 			if (!options.selected || selectionFound) {
 				processing = true;
@@ -202,7 +205,7 @@ this.singlefile.extension.core.content.main = this.singlefile.extension.core.con
 				options.infobarContent = ui.prompt("Infobar content", options.infobarContent) || "";
 			}
 			page = await processor.getPageData();
-			if (options.selected) {
+			if (options.selected || options.optionallySelected) {
 				ui.unmarkSelection();
 			}
 			ui.onEndPage();

+ 1 - 1
extension/ui/bg/ui-commands.js

@@ -33,7 +33,7 @@ singlefile.extension.ui.bg.commands = (() => {
 			if (command == "save-tab") {
 				const allTabs = await singlefile.extension.core.bg.tabs.get({ currentWindow: true, active: true });
 				allTabs.length = 1;
-				singlefile.extension.core.bg.business.saveTabs(allTabs, { selected: true });
+				singlefile.extension.core.bg.business.saveTabs(allTabs, { optionallySelected: true });
 			}
 			if (command == "save-all-tabs") {
 				const allTabs = await singlefile.extension.core.bg.tabs.get({ currentWindow: true });

+ 2 - 2
extension/ui/content/content-ui-main.js

@@ -116,9 +116,9 @@ this.singlefile.extension.ui.content.main = this.singlefile.extension.ui.content
 		onEndStageTask() { }
 	};
 
-	async function markSelection() {
+	async function markSelection(optionallySelected) {
 		let selectionFound = markSelectedContent();
-		if (selectionFound) {
+		if (selectionFound || optionallySelected) {
 			return selectionFound;
 		} else {
 			selectionFound = await selectArea();