ronycmt / zen-coding

Automatically exported from code.google.com/p/zen-coding
0 stars 0 forks source link

extra space at begining when replacing ${class} in snippets - NPP plugin v0.7 #363

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. create a snippet like "issuetest" : "${id}.${class}"
2. apply on "issuetest#App.Go"
3. output: App[space].Go 

What is the expected output? What do you see instead?
expect "App.Go", but get "App .Go"

What version of the product are you using? On what operating system?
v0.7, Npp plugin, windows

Please provide any additional information below.

solution:
Change 
From: --------------------------------------
function Snippet(node, type) {
...
this.addAttribute('id', getCaretPlaceholder());
this.addAttribute('class', getCaretPlaceholder());
...
}
addAttribute: function(name, value) {
...
if (name == 'class') {
   // 'class' is a magic attribute
      a.value += ((a.value) ? ' ' : '') + value;     // <<<< TO BE MODIFIED
   } else {
      a.value = value;
   }
...
}

To: --------------------------------------------
function Snippet(node, type) {
...
this.addAttribute('id', getCaretPlaceholder());
this.addAttribute('class', getCaretPlaceholder());
...
}
addAttribute: function(name, value) {
...
if (name == 'class') {
   // 'class' is a magic attribute
      a.value += ((a.value && a.value != getCaretPlaceholder()) ? ' ' : '') + value;
   } else {
      a.value = value;
   }
...
}

Original issue reported on code.google.com by wang2...@gmail.com on 2 Nov 2012 at 4:01