brookhong / Surfingkeys

Map your keys for web surfing, expand your browser with javascript and keyboard.
https://chrome.google.com/webstore/detail/surfingkeys/gfbliohnnapiefjpjlpjnehglfpaknnc
MIT License
5.33k stars 477 forks source link

Marks lost ability to be opened in same tab? #957

Open Madd0g opened 5 years ago

Madd0g commented 5 years ago

I noticed global marks are able to select the opened tab instead of creating new ones! Amazing fix!

Sadly, I lost the ability to control whether to open the mark in the same tab. Because SK doesn't work on the "new tab" page, I often use an existing page as a "launch point", so I load one page, then use a mark to load something else in-place of the current page.

I was using this code to control whether I want a new tab or not (sort of the inverse of adding a mark, if shift is held, re-use current tab):

mapkey('`', '#10Jump to global mark (uppercase: same tab)', function(mark) {
    let upper = mark.toUpperCase();
    let newTab = upper !== mark || mark.match(/[0-9]/);
    Normal.jumpVIMark(upper, newTab);
});

I'm wondering if it's too hard to bring this functionality back?

Thanks!

brookhong commented 5 years ago

Yes, there are some changes in 0.9.44 for vim-like marks.

Since 0.9.44, there is no differentiation between local and global marks, all marks are global. You can also use small letter for global mark. And the interface for Normal.jumpVIMark was changed, newTab parameter was removed, as I thought there is no use case for that. You could use om to open new tab for a vim-like mark.

laphylee commented 5 years ago

@brookhong I love the ability to open marks in current tab too. Is there any way to add the feature in my customised js file? For example, how to get the URL of a mark?

vogler commented 4 years ago

It would be nice if this optional newTab parameter was added again. Without it people need to duplicate the code from Normal.jumpVIMark to get the same functionality.

I now have

mapkey('"', '#10Jump to vim-like mark in current tab', function(mark) {
    RUNTIME('getSettings', {
        key: "marks"
    }, function(response) {
        var markInfo = response.settings.marks[mark];
        if(markInfo) {
            document.location.href = markInfo.url;
        } else {
            Front.showBanner(`No mark of: ${mark}`);
        }
    });
});

but this does not select an already opened tab.

sethidden commented 3 years ago

If marks can't be opened in same tab anymore, I think the ' and <Ctrl-'> mappings that show up in the ? keybind guide should be just shortened to show only ', no?