technet / brackets.clipbox

Brackets extension which keeps history of copied texts and allow you to paste them back
Other
6 stars 5 forks source link

No response to Ctrl+Alt+V #1

Closed tomas-samot-O closed 10 years ago

tomas-samot-O commented 10 years ago

On the current build of brackets:

sprint 43 experimental build 0.43.0-14375 (release 287868769) build timestamp: Tue Sep 02 2014 14:41:39 GMT-0700

There is no quick open box when using the assigned short cut.

As a side note, when installing the add-on brackets does not warn you that it needs to be restarted.

technet commented 10 years ago

Have you tried restarting brackets after installing the extension?, and does it work then? I put a warning note in settings dialog that you may need to restart incase you change shortcut keys, I will try to recreate it

tomas-samot-O commented 10 years ago

I have restarted my whole PC. Also I have no options to edit settings for this add-on.

technet commented 10 years ago

Now I'm bit confused, You mentioned no option to edit settings for this add-on? please check the following screenshots , it is under Edit menu. Please let me know if you don't have these options clipbox-settings-1 clipbox-settings-2

Can you also try Ctrl+Shift+O (or Navigate -> Quick Open in menu) and then type '#' character and see you get drop down similar to following in right top hand corner clipbox-settings-3 clipbox-settings-4

tomas-samot-O commented 10 years ago

I have checked these areas and there is no sign of the settings or the # shortcut in quick open menu. 1 not working

I have also checked in the extensions folder and the files are all there.

Also restarted Brackets with and without extensions.

technet commented 10 years ago

That is interesting that you don't even have menu options, which means extension is not loaded at all. Only way to find the cause is to run 'developer tools' F12 and then 'Reload with Extensions' F5 while looking at the console to check for any exceptions, as I couldn't recreate this in my machine (and also tried on Ubuntu pc as well). If you could provide any error messages from TechNet.clipbox in developer tool console panel that would be really helpful.

tomas-samot-O commented 10 years ago

I will do this.

*EDIT Okay, its done. There does seem to be an error relating to the loading of clipbox.

https://pibin.net/?984b6294933ee365#PQKme19o3MqeL/TuHVOr+bojjAb0D2cz6Qm3fJSeoms=

Pasted full console there. Also the certificate is self signed.

*EDIT

This is the expanded version of the console:

https://pibin.net/?d78d53214d870c00#CT06+VbJfRbXmj+q6OGgN+JWp0USZyz0r9JUQCh6AF0=

On 3 Oct 2014 00:13, "technet" notifications@github.com wrote:

That is interesting that you don't even have menu options, which means extension is not loaded at all. Only way to find the cause is to run 'developer tools' F12 and then 'Reload with Extensions' F5 while looking at the console to check for any exceptions, as I couldn't recreate this in my machine (and also tried on Ubuntu pc as well). If you could provide any error messages from TechNet.clipbox in developer tool console panel that would be really helpful.

— Reply to this email directly or view it on GitHub https://github.com/technet/brackets.clipbox/issues/1#issuecomment-57724083 .

technet commented 10 years ago

Ok now I get clear idea what's happening, brackets uses loadash and it is available to any extension to use as well, so I used lodash for certain operations, now it seems like it complaining about it. The problem is to find have they restricted or changed using lodash. I will check on this.

But the issue I'm having is I'm also using same version of brackets, and it's working fine. sprint 43 experimental build 0.43.0-14375 (release 287868769) build timestamp: Tue Sep 02 2014 14:41:39 GMT-0700 So I bet this is causing by another extension(s) you may have installed. and some conflict down the line.

thanks a lot for investigation. I will go through the error log you sent and see what else could cause this to happen

technet commented 10 years ago

For example check this https://github.com/adobe/brackets/issues/5229

It is to add _ (lodash) to the brackets and even here (http://brackets.io/docs/current/modules/utils/StringUtils.html#-htmlEscape) expand the code where it says use _ instead. That means it supports _ and in the error you mentioned it is about _ is undefined so this could be to some extension which loads before mine mess up things.

I will create small extension (nothing much just use _ and show message) if that also doesn't work means you have a problem with some other extension. Or if you already familiar with implementing brackets extension you can try creating simple one which just use underscore function when loading

technet commented 10 years ago

Can you please create new folder brackets.clipboks inside the extension folder. (Show -> Extension Folder) and then under user and create new main.js file and include following code.

/*jslint vars: true, plusplus: true, devel: true, nomen: true, regexp: true, indent: 4, maxerr: 50 */
/*global define, brackets, $, _, Mustache */
define(function (require, exports, module) {
    "use strict";    
    var AppInit             = brackets.getModule("utils/AppInit");

    function loadPreferences() {
        var temp1 = 10;
        if (!_.isNaN(temp1) && temp1 > 0) {
            console.log("brackets.clipboks >> temp1 is a number:" + temp1);
        } else {
            console.log("brackets.clipboks >> temp1 is not a number");
        }

        var temp2;
        if (!_.isUndefined(temp2) && temp2.length > 0) {
            console.log("brackets.clipboks >> temp2 is not undefined:" + temp2);
        } else {
            console.log("brackets.clipboks >> temp2 is undefined");
        }

        var temp3 = "valid";
        if (!_.isUndefined(temp3) && temp3.length > 0) {
            console.log("brackets.clipboks >> temp3 is not undefined:" + temp3);
        } else {
            console.log("brackets.clipboks >> temp3 is undefined");
        }
    }
    AppInit.appReady(function () {

        loadPreferences();
    });
});

Which does nothing except using few lodash methods (and using lodash functions are recommended by brackets) so if you get same error like _ is undefined then you might have issue with other extension causing it or your brackets installation somehow" In developer tools you should see following output if this works

brackets.clipboks >> temp1 is a number:10   
brackets.clipboks >> temp2 is undefined     
brackets.clipboks >> temp3 is not undefined:valid

Let me know the status

tomas-samot-O commented 10 years ago

I will do this ASAP. Been AFK.

tomas-samot-O commented 10 years ago

I didn't get any of the above.

I got this though:

Exception when calling a 'brackets done loading' handler: /utils/AppInit.js:95
_callHandler /utils/AppInit.js:95
_dispatchReady /utils/AppInit.js:113
(anonymous function) /brackets.js:291
j thirdparty.min.js:559
k.add thirdparty.min.js:559
d.always thirdparty.min.js:559
(anonymous function) /brackets.js:289
j thirdparty.min.js:559
k.fireWith thirdparty.min.js:559
e.(anonymous function) thirdparty.min.js:559
(anonymous function) thirdparty.min.js:559
j thirdparty.min.js:559
k.fireWith thirdparty.min.js:559
e.(anonymous function) thirdparty.min.js:559
(anonymous function) thirdparty.min.js:559
j thirdparty.min.js:559
k.add thirdparty.min.js:559
(anonymous function) thirdparty.min.js:559
o.extend.each thirdparty.min.js:559
(anonymous function) thirdparty.min.js:559
o.extend.Deferred thirdparty.min.js:559
d.then thirdparty.min.js:559
(anonymous function) /project/ProjectManager.js:850
j thirdparty.min.js:559
k.fireWith thirdparty.min.js:559
e.(anonymous function) thirdparty.min.js:559
(anonymous function) /project/ProjectManager.js:512
(anonymous function) thirdparty.min.js:559
j thirdparty.min.js:559
k.fireWith thirdparty.min.js:559
e.(anonymous function) thirdparty.min.js:559
(anonymous function) /project/ProjectModel.js:518
_applyAllCallbacks /filesystem/Directory.js:122
(anonymous function) /filesystem/Directory.js:217
(anonymous function) /filesystem/impls/appshell/AppshellFileSystem.js:301
(anonymous function) /filesystem/impls/appshell/AppshellFileSystem.js:241
(anonymous function) appshell:273
ReferenceError: _ is not defined
    at loadPreferences (file:///C:/Users/Tomas/AppData/Roaming/Brackets/extensions/user/brackets.clipboks/main.js:9:14)
    at file:///C:/Users/Tomas/AppData/Roaming/Brackets/extensions/user/brackets.clipboks/main.js:31:9
    at _callHandler (/utils/AppInit.js:93:13)
    at Object._dispatchReady (/utils/AppInit.js:113:13)
    at Object.eval (/brackets.js:291:33)
    at j (file:///C:/Program%20Files%20(x86)/Brackets/www/thirdparty/thirdparty.min.js:559:26676)
    at Object.k.add [as done] (file:///C:/Program%20Files%20(x86)/Brackets/www/thirdparty/thirdparty.min.js:559:26985)
    at Object.d.always (file:///C:/Program%20Files%20(x86)/Brackets/www/thirdparty/thirdparty.min.js:559:27861)
    at eval (/brackets.js:289:30)
    at j (file:///C:/Program%20Files%20(x86)/Brackets/www/thirdparty/thirdparty.min.js:559:26676) /utils/AppInit.js:96
updateAutoBackupTime() main.js:106
AppInit 
tomas-samot-O commented 10 years ago

I did a clean install with only your extension. That didn't work.

technet commented 10 years ago

I'm still not sure why it's just you getting this error especially when brackets documentation says we must use lodash functions, anyway I bundled lodash together with the extension and release new version 0.2.1 can you please upgrade the extension and check, Please let me know the status so I can close this bug

thanks again

tomas-samot-O commented 10 years ago

That seems to have fixed all problems. Shall I close this?

Thank you

le717 commented 10 years ago

I saw this extension was updated via Twitter, and having seen the Brackets feature request for this, I decided to check it out. Upon seeing what the newest released fixed, I felt the need to make a comment here, as a fellow extension dev. :)

Lodash is in fact available to extensions. See how are using brackets.getModule() to access Brackets core scripts? You do the same thing to access lodash or any other third party modules Brackets uses. The devs have opted to make any modules, either original or third party, require explicit requests to access them and instead not just "put them out there". This is a good idea, as it does not pollute the global namespace and makes all extensions and Brackets itself much faster.

Thus, to access Bracket's copy of lodash and not bundle it yourself, simply use var _ = brackets.getModule("thirdparty/lodash");, (or in your case, add it to your import chain).

You can use this same method to access nearly every single module Brackets uses, original or third party. :)

Also, good job on avoiding deprecated APIs. I actually have a pull request in right now to remove that. :+1:

technet commented 10 years ago

Thanks a lot @le717 I actually used and able to work even without get the lodash module using getModule and I believe many others who using this extension, but the @tomas-samot raised the issue that in his machine _ causing errors. I wonder why it is behaving differently in different environments, and also in the documentation it just say use _.escape(), what does it mean then? is lodash available directly or should we include it in import chain?

First I thought using getModule("thirdparty/lodash") as I saw it in brackets core source repo. But then I checked all extensions I have installed from different developers and all of them using their own packaged versions. Moreover I saw somewhere in brackets extension guide lines that it is best to package all dependencies instead relying on core. That's why finally end up packaging lodash with the extension.

Anyway I'm learning how to write extension by going through many source codes and bracket core source as well.

I will change the code to use lodash by getModule and remove the bundled version, if that is the best way

le717 commented 10 years ago

I actually used and able to work even without get the lodash module using getModule and I believe many others who using this extension, but the @tomas-samot raised the issue that in his machine _ causing errors. I wonder why it is behaving differently in different environments

That is an excellent question. If more details can be gathered, I'd try to ask a dev on IRC chat about that.

in the documentation it just say use _.escape(), what does it mean then? is lodash available directly or should we include it in import chain?

The documentation on that particular function is probably not the clearest. When it is say use _.escape(), it is using the underscore to refer to the lodash module (an internal convention), then access the escape() function within it. It already assumes you know how to access the lodash module, and the basic information on that topic is on the wiki. As I said already, none of the Brackets modules, internal or third party, are automatically available to an extension. In order to access them, they must be imported. I think a possible exception to this is the Brackets version information, but I am probably wrong on that.

First I thought using getModule("thirdparty/lodash") as I saw it in brackets core source repo.

brackets.getModule() is only for use in extensions. Internally, Brackets uses require() to access modules, but that is not possible in extensions except to access your own modules or ones you have bundled.

But then I checked all extensions I have installed from different developers and all of them using their own packaged versions.

I haven't actually seen an extension bundle lodash directly... Authors often bundle third party modules with their extension, but that usually stems from their use of a module that Brackets does not use.

Moreover I saw somewhere in brackets extension guide lines that it is best to package all dependencies instead relying on core. That's why finally end up packaging lodash with the extension.

I've never seen that in the guidelines, but I could have overlooked it. :)

Anyway I'm learning how to write extension by going through many source codes and bracket core source as well.

That is a good way to learn, but a lot of things can be learned only by experimentation and doing it yourself. ;)

I will change the code to use lodash by getModule and remove the bundled version, if that is the best way

Not to sound like a broken record, but unless Brackets does not use the module you need or require a prerelease version, it's safe and (personally) recommended to use the internal Brackets module. Most of those modules are not going anywhere, and as long as you pay attention to development (IMO, the best way to do that is to run straight from git :smile:) and any pending deprecations or removals, you will be fine. :smiley:

technet commented 10 years ago

That is an excellent question. If more details can be gathered, I'd try to ask a dev on IRC chat about that.

Initial version simply used underscore directly and in my environment I didn't get any error. Probably many others didn't as well. That's why I created simple extension which uses _. and asked Tomas to test as in my PC it works perfectly and didn't want to get the thirdparty/lodash module. So you can try yourself whether it can be accessed without getModule() If not then the question is does this accessible because of any other extension exporting it? I don't think so.

I've never seen that in the guidelines, but I could have overlooked it. :)

Well I found it, but actually it refers to node modules, since it was talking above dependency I thought it is good to package lodash with the extension Here's the link

I haven't actually seen an extension bundle lodash directly... Authors often bundle third party modules with their extension, but that usually stems from their use of a module that Brackets does not use.

How about well known "extension rating" extension. I think I decided to package lodash after I found that even famous extensions do that :) https://github.com/dnbard/brackets-extension-rating/tree/master/extension/vendor

tomas-samot-O commented 10 years ago

So this isn't fixed then?

technet commented 10 years ago

@tomas-samot bug is fixed, the discussion was to use whether brackets' thirdparty lodash or to ship lodash with the extension. Moreover how brackets allow to use _ even without getting the module in certain environments. However issue raised by you is now fixed. Will update extension accordingly to use internal thirdparty/lodash in later release.

thanks again for your time on this issue and helping me to analyse.

technet commented 10 years ago

I closed the issue, but comments are welcome