Skip to content

Commit d3c61fa

Browse files
dset0xtimss
authored andcommitted
:write: resolve filename when only path given (#738)
1 parent 2aa81ee commit d3c61fa

File tree

3 files changed

+14
-3
lines changed

3 files changed

+14
-3
lines changed

common/content/buffer.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1293,6 +1293,15 @@ const Buffer = Module("buffer", {
12931293
if (filename) {
12941294
let file = io.File(filename);
12951295

1296+
if (file.exists() && file.isDirectory()) {
1297+
if (doc.doctype !== null) {
1298+
filename = OS.Path.join(filename, document.title + ".html");
1299+
} else {
1300+
filename = OS.Path.join(filename, filename = doc.location.pathname.split("/").pop());
1301+
}
1302+
file = io.File(filename)
1303+
}
1304+
12961305
liberator.assert(!file.exists() || args.bang, "File exists (add ! to override)");
12971306

12981307
chosenData = { file: file, uri: window.makeURI(doc.location.href, doc.characterSet) };

common/locale/en-US/browsing.xml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -470,11 +470,12 @@ have the following possibilities:
470470

471471
<item>
472472
<tags>:w :write :sav :saveas</tags>
473-
<spec>:sav<oa>eas</oa><oa>!</oa> <oa>file</oa></spec>
473+
<spec>:sav<oa>eas</oa><oa>!</oa> <oa>file|directory</oa></spec>
474474
<description>
475475
<p>
476-
Save current web page to disk. If <oa>file</oa> is omitted, save to the page's
477-
default filename. Existing documents will only be overwritten if <oa>!</oa> is given.
476+
Save current web page to disk. If <oa>file</oa> is omitted, or a <oa>directory</oa>
477+
is given save to the page's default filename. Existing documents will only be overwritten
478+
if <oa>!</oa> is given.
478479
</p>
479480
</description>
480481
</item>

vimperator/NEWS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
* new: support <label> for <input type=file>
44
* new: fire 'change' event on file upload
55
* fix search highlighting (hlsearch) in firefox 51
6+
* allow passing a <directory> to `:w` instead of a complete <file>
67
* fix ssl icon in statusbar
78
* fix "preferences" button in Firefox add-ons page
89
* disable urlseparator by default as its unexpected behaviour irritates users

0 commit comments

Comments
 (0)