[TxMt] Bug report: Ruby error when running "Comment Line" in some Terraform documents

Alex Chan alex at alexwlchan.net
Thu Mar 2 20:48:39 UTC 2017


I’ve hit a bug when using “Comment Line” in Terraform documents,
although it only occurs on certain lines.


# Steps to reproduce

1. Install the Terraform bundle.  TextMate > Preferences > Bundles >
Terraform.

2. Create a file called "~/Desktop/example.tf" and change the document
syntax to "Terraform".

3. Enter the following contents in the file (between the '===' bars):

===
variable "aws_region" {
 default = "us-east-1"
}


===

Note that line 4 contains whitespace, although the exact whitespace
chars seem to be arbitrary.

4. Place the cursor as follows:
  a) At the start of line 1
  b) Select all of line 1
  c) Select all of line 4 (whitespace)
  d) At the start of line 4.
  After each, press ⌘+/ to Toggle Comment.


# Expected results

a/b) Line 1 will be commented out.
c/d) Line 4 will be commented out.

Note: in Terraform syntax, a comment is denoted by /* ... */


# Actual results

d) Works correctly.

All of a)-c) result in 'Failure running “Comment Line”.', with different
errors:

a) Comment Line:140:in `<main>': undefined method `to_a' for
"\u0000variable \"aws_region\" {":String (NoMethodError)
b) Comment Selection:140:in `<main>': undefined method `to_a' for
"variable \"aws_region\" {\n":String (NoMethodError)
${0:}
c) Comment Selection:140:in `<main>': undefined method `to_a' for " 
\n":String (NoMethodError)
${0:}

Broadly similar – it just seemed a little odd that it doesn’t also
affect the case where your cursor is on a line containing whitespace.


# Environment

* macOS 10.12.1 (16B2657)
* TextMate version 2.0-rc.7
* ruby 2.0.0p648 (2015-12-16 revision 53162) [universal.x86_64-darwin16]


More information about the textmate mailing list