atom / toggle-quotes

An Atom package to toggle between single and double quotes
MIT License
77 stars 36 forks source link

Not really working? #2

Closed karan closed 9 years ago

karan commented 10 years ago

Maybe I'm doing something wrong, but this doesn't seem to work for me.

Tried, cmd+shift+', cntr+shift+' and all combinations. On Mavericks.

bbudd commented 10 years ago

Yep, same issue here. Works sporadically, more not than working.

karan commented 10 years ago

Good it's not just me.

nathansobo commented 10 years ago

In situations where you expect it to work and it isn't, could you run the "Editor: Log Cursor Scope" command? It only works in situations the grammar identifies as quoted strings. That's my first thought as to what might be going wrong.

karan commented 10 years ago

Nope. Still not working.

nathansobo commented 10 years ago

I forgot to mention, could you open the dev tools and paste the output of the "Log Cursor Scope" command in the location where toggle quotes isn't working?

bbudd commented 10 years ago

["source.js","string.quoted.single.js", "punctuation.definition.string.end.js"]

Also FYI - my first thought was that something had higher selector precedence than toggle quotes. Unfortunately, it's the only thing that shows up in the keybinding resolver for the ctrl-" keybinding.

nathansobo commented 10 years ago

Weird. Do you have an example file you'd be comfortable sharing in a gist so I can try to reproduce this?

Also, just in case, any errors in your dev tools console?

bbudd commented 10 years ago

yes errors, but none related to your plugin. And I emailed you the gist address.

probablycorey commented 10 years ago

@bbudd @karan, I can't reproduce this bug. If you are still running into this please reopen this issue :smile:!

nijikokun commented 10 years ago

I have to run the command twice for it to work.

nijikokun commented 10 years ago

It happens when you have selected text, I can get it to work correctly when you place the cursor in-between them.

nathansobo commented 10 years ago

Looking into this now. I'm having trouble reproducing the bad behavior. I'm able to toggle quotes with both an empty and non-empty selection. Can you help me with specific reproduction steps, and maybe a content snippet that exhibits the issue? Thanks!

toggle-quotes

nijikokun commented 10 years ago

Select the whole line including the quotes, that is how I can reproduce

On Fri, Sep 26, 2014 at 2:39 PM, Nathan Sobo notifications@github.com wrote:

Looking into this now. I'm having trouble reproducing the bad behavior. I'm able to toggle quotes with both an empty and non-empty selection. Can you help me with specific reproduction steps, and maybe a content snippet that exhibits the issue? Thanks!

[image: toggle-quotes] https://cloud.githubusercontent.com/assets/1789/4427942/9300b8a4-45c5-11e4-941e-8f901868c0ed.gif

— Reply to this email directly or view it on GitHub https://github.com/atom/toggle-quotes/issues/2#issuecomment-57024029.

jaredmoody commented 10 years ago

I don't know if this is the same issue, but I can't get this plugin to work at all. I'm using Atom 0.140.0 on OS X.

I'm using a file like this:

# example.coffee
console.log "Hello, World"

Placing the cursor in the string and invoking the command does nothing, either via the command palette or keyboard shortcut.

jaredmoody commented 10 years ago

Update: I uninstalled and re-installed the plugin and now it works fine.

pedronauck commented 9 years ago

It's kinda weird, but to me I changed this:

'atom-workspace':
  'cmd-"': 'toggle-quotes:toggle'

by that:

'.workspace':
  'cmd-"': 'toggle-quotes:toggle'

and now workds perfectly!

mafredri commented 9 years ago

Unsure if related, but I have the following Puppet code:

    exec { "Installing godep for managing Go dependencies":
        command     => "go get github.com/tools/godep",
        environment => ["GOPATH=${workspace}"],
        path        => "/usr/bin",
        creates     => "${workspace}/bin/godep",
        require     => File['/usr/bin/go'],
    }

The toggle seems to work with all the assignment lines (=>), but the exec line cannot be converted from double to single quotes. Weird.

monkeymonk commented 9 years ago

Still not working... any clue ? Also tried to set another keymap but still not working! :'-(

Arcanemagus commented 9 years ago

I'm seeing this somewhat randomly throughout several files in Atom 0.204.0. Some examples that demonstrate the issue in a completely clean installation that only has the toggle-quotes plugin installed:

<!DOCTYPE html>
<html lang='en'> <!-- Works -->
    <body class='text'></body> <!-- Fails -->
</html>
<?php
function f_name() {
    if ($arry['asdf']) { // Fails
        $var = "text"; // Works
    }
}
?>

I'm pretty sure that this isn't toggle-quote's that is the problem here, but rather the Atom API calls that are at fault. When debugging the code for this plugin it seems that the calls to editor.getTextInBufferRange(range); are returning only parts of the string instead of properly starting with the initial quote character. With the HTML example no matter the cursor position the text is set to "text'>". Oddly enough when the cursor is between the ' and > Atom still thinks the cursor is within a string.quoted.single.html scope. The PHP code snippet is similar, the lines that are failing seem to have their range offset by one.

It doesn't seem that the editor.displayBuffer.bufferRangeForScopeAtPosition() hack is at fault here since even using the official (but incorrect for multiple cursors according to https://discuss.atom.io/t/multiple-cursor-issues/7369) editor.getTextInBufferRange(editor.bufferRangeForScopeAtCursor('string.quoted')) returns the "off-by-one" text selection.

As I'm somewhat new to Atom I'm not exactly sure where in Atom this could be getting screwed up, but hopefully this information can point somebody in the right direction.

nathansobo commented 9 years ago

toggle-quotes

I'm having trouble reproducing this on master (which includes everything in 0.204.0). As you can see in this gif, I'm able to toggle quotes in the first example.

Arcanemagus commented 9 years ago

Interestingly it works on my work computer (Win7x64, Atom 0.204.0), but but is failing on my home computer (Win8.1x64, Atom 0.204.0) and a Win10 VM I installed a fresh copy of Atom on. All see if I can figure out what the differences are later today.

Arcanemagus commented 9 years ago

This seems to be a somewhat random issue, both of the above snippets work on both of my computers now :unamused:.

Currently at least the following snippet is showing the issue on both my work and home computers, as well as a completely blank profile (with just this plugin):

<?php
function get_hist($attr) {
    $max = $bounds[0]['max_val'];
}
?>
Arcanemagus commented 9 years ago

I'm unable to reproduce this issue on any of my 3 installations of Atom as of 1.0.0. Is anyone else still seeing this issue?

jaredmoody commented 9 years ago

:+1: I'm no longer seeing this issue on 1.0.0

winstliu commented 9 years ago

Ok, I'm going to close this for now. If anyone can still reproduce this issue on 1.0.0+, please comment here!

ipaintcode commented 8 years ago

I just installed this package and it's mostly not working on Atom 1.8.0 (OS X 10.11.5) with the latest toggle quotes. Ruby files it works but JavaScript, CSS, HTML, Handlebars etc... no dice.