jtokoph / auto-detect-indentation

Auto detect indentation of files in Atom
MIT License
39 stars 6 forks source link

Detects indentation based on comments #9

Closed Stanzilla closed 8 years ago

Stanzilla commented 8 years ago

I have a lua file here that starts with a few comments that are indented with 3 spaces while the remaining file (actual code) is indented with 4 spaces. Your package reports 3 spaces as indentation of the file, is there a way the detection could be changed to ignore comments?

jtokoph commented 8 years ago

Can you update to version 0.5.0 and see if you still have this issue? I think I found a solution to re-checking after tokenization

Stanzilla commented 8 years ago

Hrm nope, still detects it as 3 spaces, here's the top of the file as an example:

--[[ Transmisson.lua
This file contains all transmission related functionality, e.g. import/export and chat links.
For that it hooks into the chat frame and addon message channels.

This file adds the following API to the WeakAuras object:

DisplayToString(id, forChat)
   Converts the display id to a plain text string

DisplayToTableString(id)
   Converts the display id to a formatted table

ShowDisplayTooltip(data, children, icon, icons, import, compressed, alterdesc)
   Shows a tooltip frame for an aura, which allows for importing if import is true

ImportString(str)
   Imports an aura from a string

]]--

-- Lua APIs
local tinsert, tconcat, tremove = table.insert, table.concat, table.remove
local fmt, tostring, string_char, strsplit = string.format, tostring, string.char, strsplit
local select, pairs, next, type, unpack = select, pairs, next, type, unpack
local loadstring, assert, error = loadstring, assert, error
local setmetatable, getmetatable, rawset, rawget = setmetatable, getmetatable, rawset, rawget
local bit_band, bit_lshift, bit_rshift = bit.band, bit.lshift, bit.rshift
local coroutine = coroutine

local WeakAuras = WeakAuras;
local L = WeakAuras.L;

local version = 1421;
local versionString = WeakAuras.versionString;

local regionOptions = WeakAuras.regionOptions;
local regionTypes = WeakAuras.regionTypes;
local event_types = WeakAuras.event_types;
local status_types = WeakAuras.status_types;

-- local functions
local encodeB64, decodeB64, tableAdd, tableSubtract, DisplayStub, removeSpellNames
local CompressDisplay, DecompressDisplay, ShowTooltip, TableToString, StringToTable
local RequestDisplay, TransmitError, TransmitDisplay

-- GLOBALS: WeakAurasOptionsSaved WeakAurasSaved UIParent

local bytetoB64 = {
    [0]="a","b","c","d","e","f","g","h",
    "i","j","k","l","m","n","o","p",
    "q","r","s","t","u","v","w","x",
    "y","z","A","B","C","D","E","F",
    "G","H","I","J","K","L","M","N",
    "O","P","Q","R","S","T","U","V",
    "W","X","Y","Z","0","1","2","3",
    "4","5","6","7","8","9","(",")"
}
rogerhub commented 8 years ago

@Stanzilla The 0.5.0 version fixes the issue when I try loading your example file. You have the language-lua plugin installed right?

Stanzilla commented 8 years ago

I do, yes. See http://i.imgur.com/a26XiFO.png though

jtokoph commented 8 years ago

It's always going to show 3 spaces on the lines that are three spaces. But what happens if you press tab on one of the blank lines. How many spaces does it insert?

Stanzilla commented 8 years ago

It now displays 4 spaces even on the lines with 3 spaces in the comments so I guess it is fixed. All I did is wait and update another (unrelated) extension. Maybe I was missing an event trigger so it updates? Anyway, thanks for the fix!

Stanzilla commented 8 years ago

Was probably this https://github.com/atom/atom/pull/11101