Coder Social home page Coder Social logo

python-indent's People

Contributors

alix-rm avatar dspeckhals avatar kbrose avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

python-indent's Issues

Uncaught TypeError: Cannot read property 'getGrammar' of undefined

[Enter steps to reproduce:]

  1. Hit Enter in commit message area after typing some text in the Git Dock Panel.

Atom: 1.18.0-beta0 x64
Electron: 1.3.15
OS: Mac OS X 10.12.4
Thrown From: python-indent package 1.0.2

Stack Trace

Uncaught TypeError: Cannot read property 'getGrammar' of undefined

At /Users/satish/.atom/packages/python-indent/lib/python-indent.js:9

TypeError: Cannot read property 'getGrammar' of undefined
    at PythonIndent.indent (/packages/python-indent/lib/python-indent.js:9:24)
    at /packages/python-indent/lib/main.js:23:57)
    at CommandRegistry.module.exports.CommandRegistry.handleCommandEvent (/Applications/Atom Beta.app/Contents/Resources/app/src/command-registry.js:265:1)
    at /Applications/Atom Beta.app/Contents/Resources/app/src/command-registry.js:3:1
    at KeymapManager.module.exports.KeymapManager.dispatchCommandEvent (/Applications/Atom Beta.app/Contents/Resources/app/node_modules/atom-keymap/lib/keymap-manager.js:610:1)
    at KeymapManager.module.exports.KeymapManager.handleKeyboardEvent (/Applications/Atom Beta.app/Contents/Resources/app/node_modules/atom-keymap/lib/keymap-manager.js:401:1)
    at WindowEventHandler.module.exports.WindowEventHandler.handleDocumentKeyEvent (/Applications/Atom Beta.app/Contents/Resources/app/src/window-event-handler.js:100:1)
    at HTMLDocument.<anonymous> (/Applications/Atom Beta.app/Contents/Resources/app/src/window-event-handler.js:3:1)

Commands

     -6:37.8.0 core:save (input.hidden-input)
     -6:36.5.0 platformio-ide-terminal:focus (input.hidden-input)
     -6:28.7.0 platformio-ide-terminal:paste (textarea.)
     -6:21.8.0 core:save (input.hidden-input)
     -6:20.8.0 platformio-ide-terminal:focus (input.hidden-input)
     -6:13.9.0 platformio-ide-terminal:prev (textarea.)
  2x -6:12.6.0 platformio-ide-terminal:next (textarea.)
     -6:10.9.0 platformio-ide-terminal:prev (textarea.)
     -6:10.1.0 platformio-ide-terminal:next (textarea.)
     -0:38.6.0 core:confirm (div.github-StagingView.unstaged-changes-focused)
     -0:29 docblockr:parse-enter (input.hidden-input)
     -0:29 editor:newline (input.hidden-input)
     -0:09.6.0 core:move-up (input.hidden-input)
     -0:09.0 editor:move-to-end-of-line (input.hidden-input)
     -0:06.4.0 docblockr:parse-enter (input.hidden-input)
     -0:06.4.0 editor:newline (input.hidden-input)

Non-Core Packages

advanced-open-file 0.16.6 
atom-ctags 5.1.0 
autocomplete-python 1.8.63 
busy-signal 1.4.1 
center-line 1.2.4 
ctags-status 1.3.7 
docblockr 0.10.3 
file-icons 2.1.6 
highlight-selected 0.13.1 
incremental-search 5.2.2 
intentions 1.1.2 
linter 2.1.4 
linter-flake8 2.2.1 
linter-ui-default 1.6.0 
minimap 4.28.2 
minimap-find-and-replace 4.5.2 
minimap-git-diff 4.3.1 
minimap-highlight-selected 4.6.1 
move-by-paragraph 2.0.1 
move-panes 0.2.0 
platformio-ide-terminal 2.5.1 
project-manager 3.3.4 
python-autopep8 0.1.3 
python-indent 1.0.2 
python-tools 0.6.9 
spacegray-atom-dark-syntax 1.3.2 
split-diff 1.4.0 
sync-settings 0.8.1 
tasks 2.6.6 
todo-show 1.11.0 

Brackets after closing parenthesis

This is an awesome package! I'm actually trying to use it for writing R code, which recommends a similar indentation style. However, one difference between R and Python is that R uses brackets in function definitions. So I would start out with

f <- function(x,
              y){}

Where the {} is automatically created when I type {. My cursor would now be between the two brackets, and when I press enter I would like the following to happen:

f <- function(x,
              y){
 |
}

With the | marking the cursor position. However, it ends up like:

f <- function(x,
              y){
|
                }

I'm honestly not familiar enough with javascript/this package to code this myself, but I think this would be an awesome edition, and could be helpful for lots of R users.

Uncaught TypeError: Cannot read property '0' of undefined

[Enter steps to reproduce below:]

  1. ...
  2. ...

Atom Version: 1.5.4
System: Ubuntu 14.04.4
Thrown From: python-indent package, v0.4.1

Stack Trace

Uncaught TypeError: Cannot read property '0' of undefined

At /home/roberto/.atom/packages/python-indent/lib/python-indent.coffee:224

TypeError: Cannot read property '0' of undefined
    at PythonIndent.module.exports.PythonIndent.parseLines (/home/roberto/.atom/packages/python-indent/lib/python-indent.coffee:224:65)
    at PythonIndent.module.exports.PythonIndent.properlyIndent (/home/roberto/.atom/packages/python-indent/lib/python-indent.coffee:24:20)
    at atom-text-editor.subscriptions.add.atom.commands.add.editor:newline (/home/roberto/.atom/packages/python-indent/lib/main.coffee:17:97)
    at CommandRegistry.module.exports.CommandRegistry.handleCommandEvent (/usr/share/atom/resources/app.asar/src/command-registry.js:260:29)
    at /usr/share/atom/resources/app.asar/src/command-registry.js:3:61
    at KeymapManager.module.exports.KeymapManager.dispatchCommandEvent (/usr/share/atom/resources/app.asar/node_modules/atom-keymap/lib/keymap-manager.js:570:16)
    at KeymapManager.module.exports.KeymapManager.handleKeyboardEvent (/usr/share/atom/resources/app.asar/node_modules/atom-keymap/lib/keymap-manager.js:378:22)
    at WindowEventHandler.module.exports.WindowEventHandler.handleDocumentKeydown (/usr/share/atom/resources/app.asar/src/window-event-handler.js:97:36)
    at HTMLDocument.<anonymous> (/usr/share/atom/resources/app.asar/src/window-event-handler.js:3:61)

Commands

  2x -0:05.0 vim-mode:move-right (atom-text-editor.editor.is-focused.vim-mode.normal-mode)
     -0:04.7.0 vim-mode:move-down (atom-text-editor.editor.is-focused.vim-mode.normal-mode)
     -0:04.5.0 vim-mode:move-right (atom-text-editor.editor.is-focused.vim-mode.normal-mode)
     -0:03.7.0 vim-mode:activate-insert-mode (atom-text-editor.editor.is-focused.vim-mode.normal-mode)
 33x -0:03.4.0 core:move-right (atom-text-editor.editor.is-focused.vim-mode.insert-mode)
     -0:00.8.0 editor:newline (atom-text-editor.editor.is-focused.vim-mode.insert-mode)

Config

{
  "core": {
    "themes": [
      "seti-ui",
      "monokai-seti"
    ]
  },
  "python-indent": {}
}

Installed Packages

# User
autocomplete-python, v1.7.0
linter, v1.11.3
linter-flake8, v1.13.0
minimap, v4.20.0
monokai-seti, v0.7.0
odoo-snippets, v0.3.0
project-manager, v2.7.6
python-autopep8, v0.1.3
python-indent, v0.4.1
seti-ui, v0.9.1
vim-mode, v0.65.0

# Dev
No dev packages

Not working in .pyx/.pxd files

Hi, great package! For a project where I compile a lot of code using Cython, I would love it if the functionality also works in files with a .pyx or .pxd extension

code disappear after indentation when using multiple cursors

There is a bug where part of the code disappear after creating new lines when using multiple cursors and when indentation is required. I narrowed it down and this only happens when I enable this package.

To reproduce: create multiple cursors on a single line (either by selecting something and pressing Ctrl+d or by clicking while holding Ctrl+Shift) and then press Enter. If the new lines will require indentation, all code other than the very first newly created line will be deleted (!). At that point, you can press Ctrl+z to undo the indentation and the code reappers, but it will require manual indentation at that point. See the animation below:

ezgif-4-5a3607115891

Uncaught TypeError: Cannot read property 'length' of undefined

[Enter steps to reproduce below:]

  1. ...
  2. ...

Atom Version: 1.8.0
System: Mac OS X 10.11.5
Thrown From: python-indent package, v0.4.3

Stack Trace

Uncaught TypeError: Cannot read property 'length' of undefined

At /Users/xshare/.atom/packages/python-indent/lib/python-indent.coffee:178

TypeError: Cannot read property 'length' of undefined
    at PythonIndent.module.exports.PythonIndent.parseLines (/Users/xshare/.atom/packages/python-indent/lib/python-indent.coffee:178:20)
    at PythonIndent.module.exports.PythonIndent.properlyIndent (/Users/xshare/.atom/packages/python-indent/lib/python-indent.coffee:24:20)
    at atom-text-editor.subscriptions.add.atom.commands.add.editor:newline (/Users/xshare/.atom/packages/python-indent/lib/main.coffee:17:97)
    at CommandRegistry.module.exports.CommandRegistry.handleCommandEvent (/Applications/Atom.app/Contents/Resources/app.asar/src/command-registry.js:260:29)
    at /Applications/Atom.app/Contents/Resources/app.asar/src/command-registry.js:3:61
    at KeymapManager.module.exports.KeymapManager.dispatchCommandEvent (/Applications/Atom.app/Contents/Resources/app.asar/node_modules/atom-keymap/lib/keymap-manager.js:580:16)
    at KeymapManager.module.exports.KeymapManager.handleKeyboardEvent (/Applications/Atom.app/Contents/Resources/app.asar/node_modules/atom-keymap/lib/keymap-manager.js:388:22)
    at WindowEventHandler.module.exports.WindowEventHandler.handleDocumentKeyEvent (/Applications/Atom.app/Contents/Resources/app.asar/src/window-event-handler.js:98:36)
    at HTMLDocument.<anonymous> (/Applications/Atom.app/Contents/Resources/app.asar/src/window-event-handler.js:3:61)

Commands

     -0:02.3.0 editor:newline (atom-text-editor.editor.vim-mode.power-mode.insert-mode.is-focused)
     -0:00.5.0 core:undo (atom-text-editor.editor.vim-mode.power-mode.insert-mode.is-focused)

Config

{
  "core": {
    "disabledPackages": [
      "symbols-view"
    ],
    "excludeVcsIgnoredPaths": false
  }
}

Installed Packages

# User
activate-power-mode, v0.5.2
atom-beautify, v0.29.7
atom-ctags, v4.5.2
auto-update-packages, v1.0.1
autocomplete-clang, v0.9.3
autocomplete-python, v1.8.1
clipboard-plus, v0.5.1
color-picker, v2.1.1
emmet, v2.4.3
environment, v1.2.0
file-icons, v1.7.14
hyperclick, v0.0.36
language-latex, v0.6.1
language-lisp, v0.2.0
language-vue, v0.14.0
linter, v1.11.8
merge-conflicts, v1.4.4
minimap, v4.24.4
pigments, v0.29.2
python-autopep8, v0.1.3
python-indent, v0.4.3
python-tools, v0.6.7
rst-preview, v1.3.1
tornado-templates, v0.2.0
vim-mode, v0.65.1
vim-mode-clipboard-plus, v0.2.0
vim-mode-visual-block, v0.2.15
vue-autocomplete, v0.1.0

# Dev
No dev packages

disapearing first word of the line after newline+space highlighting and enter

The issue comes up when highlight from the end of the line above to the last leading white space on the line and hit enter.

Lets start with the following code block with too much indentation:

def a():
    def function_with_lots_of_params(param_1, param_2,
                                         param_3, param_4,
                                         very_long_parameter_name,
                                         param_6)

Highlight from right after the comma of param_2 and highlight all white space up to but not including param_3 and hit enter. And you get this:

def a():
    def function_with_lots_of_params(param_1, param_2,
		    			3, param_4,
                                         very_long_parameter_name,
                                         param_6)

The 'param_3' is clearly missing the 'param_' string and this is bad.

It works if the 'function_with_lots_of_params' is not indented itself, but even more text gets eaten #when the indent of 'function_with_lots_of_params' increases.

Stuff also disappears when the cursor is is after 'param_1,' and I hit enter.

De-dent is broken on break/continue/yield/raise/return

I am using 1.1.1 of python-indent and atom 1.20.1 on OSX. The following code results in this:

def test():
    while True:
        if True:
            break
    else:|

Expected results should be:

def test():
    while True:
        if True:
            break
        else:|

This is probably because of the de-dent change here: atom/language-python#140

It seems that both language-python and python-indent are de-denting when they encounter an item in that list of keywords, resulting in a double de-dent.

installation instruction

Thanks for putting this online. A short description of how to install this, e.g. in the readme, would be good.

IndentationError: expected an indented block

Hi guys,

I am trying to run a basic script in atom (installed python-ide-terminal) with if , but get indentation error. i have also installed python indent. Going crazy trying to figure out where is the mistake. Please, help! :-/
Screenshot 2020-11-17 at 14 24 37

Break out python parsing into separate NPM package?

Hey @DSpeckhals! Can't believe it's been years since this extension was released.

In the microsoft/vscode-python#481 thread, you suggested it may make sense to break out the python parsing engine into a separate NPM package at some point if a similar indentation extension could be written for Visual Studio Code.

I have been playing around with an initial (extremely alpha) version of one (https://marketplace.visualstudio.com/items?itemName=KevinRose.vsc-python-indent). Right now I've just copy/pasted the parsing code over, but if there was an NPM package to depend on instead I'd be happy to refactor to depend on that.

There's no real need on my end, just thought I'd suggest it as a possibility in case you were interested.

Incorrect indentation when closing hanging indent

If a hanging indent is closed after some values have been entered, it incorrectly keeps the indentation level.

Example:

x = [
    0,1,2,3]

pressing enter before the ] character results in

x = [
    0,1,2,3
    ]

instead of producing

x = [
    0,1,2,3
]

as expected. If the hanging indent were created to begin with, then the bracket would be correctly placed, this only occurs if a previously non-hanging-indented set of lines were converted to a hanging indent.

Note, however, that it is not enough simply to look for a comma. Consider the case of the (admittedly rarely used) multi-line string created via parentheses:

x = (
    'here is a multi-line string'
    ' that spans several lines without any commas'
    ' how will we detect this correctly? If this were'
    ' inside brackets, then we would want to see if there'
    ' is a comma, but since it is parentheses, there does'
    ' not need to be a comma...'
    'It appears as if there is no certain way to tell what the'
    ' indentation should be here, probably best to default to'
    ' current behavior, which is to set indentation to current indentation.'
)

x = [
    'compare the above to this',
    'where now we should close the hanging'
    'indent because there is no comma'
]

Need to think more about what the desired behavior actually is here.

End-to-End Performance

Overall, thanks to the routines in this package only being executed at a new line event, performance doesn't seem to be a big issue. However, I have noticed a couple of times (especially in large files), where I notice a sub-second blip when on enter. This may or may not be due to this actual package, but I think it would be good to create some "wild" test scenarios and see if any improvements can be made.

dictionaries throw off lastFunctionRow

Defining a dictionary throws off the lastFunctionRow variable since colons are used to define the dictionary. Looks like the lastFunctionRow variable should check similar to hanging indents to only trigger when it's the last non-commented character in the line.

Feature Request: fixing indentation in an existing code

Hi,

It would be great if we could use this wonderful package to also fix indentation on a code we wrote beforehand.
It would be helpful for when I copy code from another file from another editor, or if I just installed your package and need to reformat everything in my code. Something like the 'Reformat' feature in PyCharm.

If it is already a feature then I have not found out how to use it and instructions will be very helpful.

Thank you!
Omer.

Odd number of quotes in triple quoted string

If a triple quoted string is created using the single quote, ', and there are an odd number of non-escaped single quotes inside the string, then the string is not parsed correctly. The same happens when the triple quoted string is created with a double quote, ", and contains an odd number of non-escaped double quotes inside the string.

Example:

def f():
    '''
    This ' is a docstring, but with a floating single quote:
    '''
    x = [0, 1, 2,  # pressing enter here results in a wrong indentation!
    ]

_Commentary:_
The string parsing is currently about as simple as I think it can get, so I guess it's not surprising that there's an edge case that breaks it. I think correctly checking that we are inside a triple-quoted string will not be terribly difficult, it will just muddy up the code a bit. Sigh.

Uncaught TypeError: Cannot read property 'transact' of undefined

[Enter steps to reproduce:]

This is at least what I was doing, not sure if it reproduces 100%...

  1. code in python
  2. create a branch
  3. Add the modified file and start typing a commit message

Atom: 1.22.0 x64
Electron: 1.6.15
OS: Mac OS X 10.13
Thrown From: python-indent package 1.1.3

Stack Trace

Uncaught TypeError: Cannot read property 'transact' of undefined

At /Users/tylerholmes/.atom/packages/python-indent/lib/python-indent.js:12

TypeError: Cannot read property 'transact' of undefined
    at PythonIndent.indent (/packages/python-indent/lib/python-indent.js:12:45)
    at HTMLElement.editorNewline (/packages/python-indent/lib/main.js:23:57)
    at CommandRegistry.handleCommandEvent (/Applications/Atom.app/Contents/Resources/app/src/command-registry.js:381:36)
    at KeymapManager.module.exports.KeymapManager.dispatchCommandEvent (/Applications/Atom.app/Contents/Resources/app/node_modules/atom-keymap/lib/keymap-manager.js:621:22)
    at KeymapManager.module.exports.KeymapManager.handleKeyboardEvent (/Applications/Atom.app/Contents/Resources/app/node_modules/atom-keymap/lib/keymap-manager.js:412:28)
    at WindowEventHandler.module.exports.WindowEventHandler.handleDocumentKeyEvent (/Applications/Atom.app/Contents/Resources/app/src/window-event-handler.js:100:42)
    at HTMLDocument.<anonymous> (/Applications/Atom.app/Contents/Resources/app/src/window-event-handler.js:3:65)

Commands

  3x -2:28.8.0 core:backspace (input.hidden-input)
     -2:27.4.0 core:save (input.hidden-input)
     -2:26.9.0 core:backspace (input.hidden-input)
     -2:26.4.0 core:save (input.hidden-input)
     -2:15 editor:newline (input.hidden-input)
     -2:12.2.0 core:backspace (input.hidden-input)
     -2:09.2.0 core:move-left (input.hidden-input)
     -2:09.0 editor:newline (input.hidden-input)
     -2:06.1.0 core:backspace (input.hidden-input)
     -2:05.4.0 core:save (input.hidden-input)
     -1:49.4.0 core:backspace (input.hidden-input)
     -1:48.4.0 core:save (input.hidden-input)
     -1:11.2.0 autocomplete-plus:confirm (input.hidden-input)
     -1:10.9.0 core:save (input.hidden-input)
  3x -0:23.3.0 core:backspace (input.hidden-input)
  2x -0:06.4.0 editor:newline (input.hidden-input)

Non-Core Packages

autocomplete-clang 0.11.4 
autocomplete-python 1.10.3 
busy-signal 1.4.3 
copy-as-rtf 0.9.3 
highlight-selected 0.13.1 
intentions 1.1.5 
language-cmake 0.3.0 
language-restructuredtext 1.1.0 
linter 2.2.0 
linter-clang 4.1.2 
linter-flake8 2.2.1 
linter-json-lint 0.1.2 
linter-ui-default 1.6.10 
python-indent 1.1.3 
rest-client 1.3.1 
todo-show 2.1.0 

Source code "lastFunctionRow" variable and documentation

The source code contains the variable lastFunctionRow along with some documentation which incorrectly suggests that lastFunctionRow can only refer to the last row that contained the end of a function definition. In fact, it can refer to the end of the declaration for other control blocks such as if, for, except, class, etc..

Note that these situations are being handled correctly, so only the variable name and some of the associated documentation needs to be changed.

(I can work on this this week, but wanted to get it down in writing before I began.)

trailing space before newline prevents indentation

If a space is inserted before pressing RETURN, then no indentation occurs. For example:

x = [[0, 1, 2], [3, 4, <cursor here>]]

(note the space before the cursor) turns into

x = [[0, 1, 2], [3, 4, 
<cursor here>]]

after pressing RETURN. On the other hand,

x = [[0, 1, 2], [3, 4,<cursor here>]]

(note no space before cursor) correctly turns into

x = [[0, 1, 2], [3, 4,
                 <cursor here>]]

Slow loading time?

Hi,

First of all, great repo - thanks for it! I just want to mention that it's currently (by far) the slowest-loading plugin, at 687ms. The second slowest is only 24ms. I wonder if there's a bug or if there's anything that can be done about it?

I'm on atom 1.15, macOS 10.12.

Thanks!

Indentation breaks on empty strings inside brackets

Hi,
I've noticed that empty strings in lists/dictionaries break the indentation. For example:

x = ['a', 'b', '', 'c']
    <cursor>

a = {'a' : 1,
     'b' : '',
     'c' : 2}
    <cursor>

indentation lines up to the opening bracket, instead of being reset as expected. Hanging indent stops working generally for the rest of the file.

Uncaught TypeError: Cannot read property 'testSync' of undefined

[Enter steps to reproduce:]

  1. On a Python document write a statement that includes arguments between parenthesis.
  2. Put the cursor just after the open parenthesis and press enter. The line should be broken and the continuation line indented. Instead, the error is raised and the continuation line remains unindented.

Atom: 1.23.0-beta0 x64
Electron: 1.6.15
OS: Mac OS X 10.13.1
Thrown From: python-indent package 1.1.2

Stack Trace

Uncaught TypeError: Cannot read property 'testSync' of undefined

At /Users/albireo/.atom/packages/python-indent/lib/python-indent.js:322

TypeError: Cannot read property 'testSync' of undefined
    at PythonIndent.indentHanging (/packages/python-indent/lib/python-indent.js:322:19)
    at PythonIndent.indent (/packages/python-indent/lib/python-indent.js:37:18)
    at HTMLElement.editorNewline (/packages/python-indent/lib/main.js:23:57)
    at CommandRegistry.handleCommandEvent (/Applications/Atom Beta.app/Contents/Resources/app/src/command-registry.js:388:36)
    at KeymapManager.module.exports.KeymapManager.dispatchCommandEvent (/Applications/Atom Beta.app/Contents/Resources/app/node_modules/atom-keymap/lib/keymap-manager.js:621:22)
    at KeymapManager.module.exports.KeymapManager.handleKeyboardEvent (/Applications/Atom Beta.app/Contents/Resources/app/node_modules/atom-keymap/lib/keymap-manager.js:412:28)
    at WindowEventHandler.handleDocumentKeyEvent (/Applications/Atom Beta.app/Contents/Resources/app/src/window-event-handler.js:108:40)

Commands

  3x -1:03.0 core:move-left (input.hidden-input)
     -1:02.2.0 editor:newline (input.hidden-input)
     -1:01.5.0 core:move-down (input.hidden-input)
 18x -1:01.4.0 core:move-right (input.hidden-input)
  7x -1:00.2.0 core:move-left (input.hidden-input)
     -0:59.2.0 core:move-right (input.hidden-input)
 16x -0:50.5.0 core:backspace (input.hidden-input)
     -0:46.6.0 editor:move-to-first-character-of-line (input.hidden-input)
     -0:46 snippets:next-tab-stop (input.hidden-input)
     -0:46 snippets:expand (input.hidden-input)
     -0:46 editor:indent (input.hidden-input)
     -0:45.6.0 core:save (input.hidden-input)
  5x -0:45.1.0 core:backspace (input.hidden-input)
     -0:43.2.0 editor:newline (input.hidden-input)
  4x -0:05.4.0 core:backspace (input.hidden-input)
     -0:03.7.0 editor:newline (input.hidden-input)

Non-Core Packages

atom-beautify 0.30.6 
atom-ide-ui 0.5.4 
atom-jinja2 0.6.0 
auto-detect-indentation 1.3.0 
autocomplete-clang 0.11.4 
autocomplete-emojis 2.5.0 
autocomplete-paths 2.12.1 
autocomplete-python 1.10.3 
autocomplete-python-jedi 1.10.3-0 
autocomplete-system-paths 1.0.0 
busy-signal 1.4.3 
file-header 1.13.7 
file-icons 2.1.13 
file-type-icons 1.3.4 
git-plus 7.10.0 
git-time-machine 1.5.9 
highlight-selected 0.13.1 
ide-python 0.2.3 
imdone-atom 2.2.7 
imdone-atom-github 0.1.11 
intentions 1.1.5 
language-cython 0.3.0 
language-fish-shell 1.0.5 
language-idl 0.4.0 
language-latex 1.1.1 
language-markdown 0.25.1 
language-restructuredtext 1.1.0 
language-viml 1.1.6 
last-cursor-position 0.9.2 
latex 0.49.0 
latex-autocomplete 1.0.0 
latex-completions 0.3.3 
linter 2.2.0 
linter-clang 4.1.2 
linter-coffeescript 1.0.0 
linter-flake8 2.2.1 
linter-pydocstyle 0.4.7 
linter-pylint 2.1.0 
linter-spell 0.15.0 
linter-spell-rst 0.4.0 
linter-ui-default 1.6.10 
markdown-preview-plus 2.4.16 
markdown-writer 2.7.3 
merge-conflicts 1.4.5 
multi-wrap-guide 1.0.0 
nord-atom-syntax 0.9.1 
nord-atom-ui 0.11.0 
nucleus-dark-ui 0.12.3 
open-terminal-here 2.3.1 
organized 0.8.1 
project-manager 3.3.5 
python-indent 1.1.2 
python-tools 0.6.9 
revert-buffer 0.6.0 
split-diff 1.5.1 
Sublime-Style-Column-Selection 1.7.4 
tabs-to-spaces 1.0.3 
toggle-quotes 1.0.1 

Indentation double what it should be

When I have "Hanging Indent Tabs" set to 1, and my indentation setting set to 4 spaces, this gives me a total of 8 spaces when creating a hanging indent. Likewise, when "Hanging Indent Tabs" is set to 2, this gives me a total of 16 spaces when creating a hanging indent. See the gif below for clarification.

When I deactivate this package, I have no indentation at all when creating a hanging indent, which leads me to believe that I'm not getting a "double effect" from using python-indent and language-python.

peek 2017-12-12 18-18

There are no other packages interfering:
image

My Atom specs are:

> atom --version
Atom    : 1.22.1
Electron: 1.6.15
Chrome  : 56.0.2924.87
Node    : 7.4.0

and using package version: 1.1.4.

The Hanging-Type Indent Will Fail on Windows with CRLF Line Ending

The hanging-type indent will fail if the file uses CRLF line ending, which is the default in Atom editor in Windows. After changing the line ending to LF, the package works fine.

I didn't see any hint about line ending selection in doc or README. It would be better this is fixed or emphasized in the doc.

font

Thanks for this amazing package, really enjoy it ๐Ÿ˜Š

BTW, what is the font you use in the demo GIF? I like that font look better over the default of Atom uses on OSX

Plugin doesn't work when Tree Sitter Parser are enabled

Atom is currently testing Tree Sitter parsers, and the (experimental) setting can already be enabled in the core settings page. Since this will eventually be the default, I just wanted to give a heads up that python-indent is not working if these new parsers are enabled.

Incorrect indentation with def or function

it is possible to choose the number of indentations for a function and for a def function ?

example:

def long_function_name(
        var_one, var_two, var_three,
        var_four):
    print(var_one)

foo = long_function_name(
    var_one, var_two,
    var_three, var_four)
print(var_one)

ps: it's really a good package :)

Uncaught TypeError: Cannot read property 'search' of undefined

Steps made:

  1. pulled files from git repository;
  2. hit 'Undo' last commit;
  3. started rewriting a commit message;
  4. hit 'enter' to go to the next line of this commit message.

Atom: 1.39.1 x64
Electron: 3.1.10
OS: Ubuntu 18.04.3
Thrown From: python-indent package 1.2.3

Stack Trace

Uncaught TypeError: Cannot read property 'search' of undefined

At /usr/share/atom/resources/app/static/<embedded>:11

TypeError: Cannot read property 'search' of undefined
    at indentationLevel (/packages/python-indent/node_modules/python-indent-parser/lib/index.js:11:17)
    at nextIndentationLevel (/packages/python-indent/node_modules/python-indent-parser/lib/index.js:47:16)
    at Object.indentationInfo (/packages/python-indent/node_modules/python-indent-parser/lib/index.js:15:22)
    at /packages/python-indent/lib/main.js:42:66
    at Array.forEach (<anonymous>)
    at /packages/python-indent/lib/main.js:33:43
    at TextBuffer.transact (/usr/share/atom/resources/app/static/<embedded>:11:491299)
    at TextEditor.transact (/usr/share/atom/resources/app/static/<embedded>:11:24215)
    at HTMLElement.indent (/packages/python-indent/lib/main.js:31:12)
    at CommandRegistry.handleCommandEvent (/usr/share/atom/resources/app/static/<embedded>:11:348736)
    at KeymapManager.dispatchCommandEvent (/usr/share/atom/resources/app/static/<embedded>:11:1248155)
    at KeymapManager.handleKeyboardEvent (/usr/share/atom/resources/app/static/<embedded>:11:1244289)
    at WindowEventHandler.handleDocumentKeyEvent (/usr/share/atom/resources/app/static/<embedded>:11:283942)

Commands

     -0:23.4.0 editor:newline (input.hidden-input)

Non-Core Packages

busy-signal 2.0.1 
intentions 1.1.5 
linter 2.3.0 
linter-python-pep8 0.2.0 
linter-ui-default 1.7.1 
minimap 4.29.9 
python-autopep8 0.1.3 
python-indent 1.2.3 
python-tools 0.6.9 
python-yapf 0.14.0 
script 3.18.1 
vim-mode-plus 1.36.0 

Multi-cursor indent

The auto-indentation only works for the cursor placed last. It would be really nice if it indented for all cursors instead.
e.g.:

print("1"\cursor)
print("2"\cursor)

After hitting enter:
Current:

print("1"
)
print("2"
      )

Desired:

print("1"
      )
print("2"
      )

No newline created when text already on next line

Create a python file that has three lines:

l = [0, 1, 2, 3]
l2 = map(
x = 1.0

Hit enter on the second line, after map(, and instead of creating a new line with the proper indentation, the line containing x = 1.0 is indented and no newline is created.

Using python indent version 0.3.3, Atom version 1.5.3

[FEATURE] De-dent after appropriate statements

What statements should trigger a de-dent? I can think of the following:

  • return
  • yield
  • continue
  • break
  • raise (?)

Are there times when it would be incorrect to dedent after such statements (assuming they were not found in a string, a comment, or as a substring of a different variable/statement such as return_values())?

Indentation level set by already-closed brackets

It seems like the indentation level will set itself to the most recent open bracket, even if it has already been closed. Consider:

x = [[0, 1, 2], [3, 4, 5],<cursor here>]

turns into

x = [[0, 1, 2], [3, 4, 5],
                 <cursor here>]]

instead of

x = [[0, 1, 2], [3, 4, 5],
     <cursor here>]

as expected.

version:
Using python-indent version 0.3.3 (specifically, without commit 6d7adb5 that fixed #5)

Bug in Indentation for Return

Improper indentation occurs when entering an empty hanging indent on a line which contains return:

"|" is used as cursor placement.


Actual

def func():
    return (
    |
)

Expected

def func():
    return (
        |
    )

Everything works as expected when the contents are not empty:

def func():
    return (1, 2, 3,
            |)

Failed to activate the python-indent package

[Enter steps to reproduce below:]

  1. ...
  2. ...

Atom Version: 1.5.3
System: Ubuntu 15.10
Thrown From: python-indent package, v0.3.4

Stack Trace

Failed to activate the python-indent package

At PythonIndent is not a function

TypeError: PythonIndent is not a function
    at Object.module.exports.activate (/home/b3ni/.atom/packages/python-indent/lib/main.coffee:27:25)
    at Package.module.exports.Package.activateNow (/usr/share/atom/resources/app.asar/src/package.js:181:20)
    at /usr/share/atom/resources/app.asar/src/package.js:155:32
    at Package.module.exports.Package.measure (/usr/share/atom/resources/app.asar/src/package.js:92:15)
    at /usr/share/atom/resources/app.asar/src/package.js:148:26
    at Package.module.exports.Package.activate (/usr/share/atom/resources/app.asar/src/package.js:145:34)
    at PackageManager.module.exports.PackageManager.activatePackage (/usr/share/atom/resources/app.asar/src/package-manager.js:526:21)
    at /usr/share/atom/resources/app.asar/node_modules/settings-view/lib/package-manager.js:385:60
    at exit (/usr/share/atom/resources/app.asar/node_modules/settings-view/lib/package-manager.js:73:16)
    at triggerExitCallback (/usr/share/atom/resources/app.asar/src/buffered-process.js:213:47)
    at /usr/share/atom/resources/app.asar/src/buffered-process.js:227:18
    at Socket.<anonymous> (/usr/share/atom/resources/app.asar/src/buffered-process.js:98:18)
    at emitOne (events.js:82:20)
    at Socket.emit (events.js:169:7)
    at Pipe._onclose (net.js:469:12)

Commands

     -0:18.8.0 project-viewer:toggle (atom-pane.pane.active)
     -0:12.6.0 settings-view:check-for-package-updates (atom-workspace.workspace.scrollbars-visible-always.theme-monokai.theme-atom-dark-ui)

Config

{
  "core": {
    "autoHideMenuBar": true,
    "disabledPackages": [
      "color-picker",
      "emmet",
      "linter-pep8"
    ],
    "ignoredNames": [
      ".git"
    ],
    "packagesWithKeymapsDisabled": [
      "language-php",
      "highlight-selected"
    ],
    "projectHome": "/home/b3ni/workspace",
    "themes": [
      "atom-dark-ui",
      "monokai"
    ]
  },
  "python-indent": {}
}

Installed Packages

# User
django-atom, v0.2.4
file-icons, v1.6.15
highlight-selected, v0.11.2
linter, v1.11.3
minimap, v4.19.0
monokai, v0.18.0
project-viewer, v0.2.31
python-indent, v0.3.4
react, v0.14.1

# Dev
No dev packages

Uncaught TypeError: Cannot read property 'getBuffer' of undefined

[Enter steps to reproduce:]

  1. Focus a textarea in a git pane. (This pane is created by github core package.)
    image

  2. Input a breakline.

Atom: 1.36.1 x64
Electron: 2.0.18
OS: Mac OS X 10.14.4
Thrown From: python-indent package 1.2.2

Stack Trace

Uncaught TypeError: Cannot read property 'getBuffer' of undefined

At /Users/ikngtty/.atom/packages/python-indent/lib/main.js:9

TypeError: Cannot read property 'getBuffer' of undefined
    at HTMLElement.indent (/packages/python-indent/lib/main.js:9:27)
    at CommandRegistry.handleCommandEvent (/Applications/Atom.app/Contents/Resources/app/static/<embedded>:11:350065)
    at KeymapManager.t.exports.KeymapManager.dispatchCommandEvent (/Applications/Atom.app/Contents/Resources/app/static/<embedded>:11:1212791)
    at KeymapManager.t.exports.KeymapManager.handleKeyboardEvent (/Applications/Atom.app/Contents/Resources/app/static/<embedded>:11:1208925)
    at WindowEventHandler.handleDocumentKeyEvent (/Applications/Atom.app/Contents/Resources/app/static/<embedded>:11:285300)

Commands

     -0:09.4.0 github:toggle-git-tab (atom-pane.pane)
     -0:06.1.0 docblockr:parse-enter (input.hidden-input)
     -0:06.1.0 editor:newline (input.hidden-input)

Non-Core Packages

achievements 0.9.0 
activate-power-mode 2.7.0 
advanced-open-file 0.16.8 
atom-ide-ui 0.13.0 
atom-slime 2.8.0 
autoclose-tags 0.2.4 
browser-plus 0.0.98 
busy-signal 2.0.1 
docblockr 0.13.7 
docker 0.8.0 
dockerletion 0.2.0 
document-outline 2.1.2 
elm-format 3.2.0 
elmjutsu 9.11.0 
emmet 2.4.3 
Ensime 0.42.0 
file-icons 2.1.32 
format-shell 2.1.6 
formatter 2.12.4 
formatter-gofmt 1.0.1 
git-control 0.9.0 
git-plus 8.6.3 
git-time-machine 2.1.0 
go-debug 1.6.2 
go-plus 6.1.0 
go-signature-statusbar 1.2.3 
goto 1.8.3 
highlight-selected 0.16.0 
html-elmfier 0.7.0 
Hydrogen 2.9.0 
hyperclick 0.0.0 
ide-haskell 2.4.0 
ide-python 1.4.1 
intentions 1.1.5 
js-hyperclick 1.13.3 
jumpy 5.0.2 
language-docker 1.1.8 
language-elm 1.5.0 
language-fish-shell 1.1.0 
language-gitignore 0.3.0 
language-haskell 1.18.0 
language-javascript-jsx 0.3.7 
language-lisp 0.2.0 
language-markdown 0.29.0 
language-matlab 0.2.1 
language-ocaml 1.9.5 
language-pip 2.0.0 
language-plantuml 0.2.0 
language-scala 1.1.10 
language-viml 1.1.9 
linter 2.3.0 
linter-checkbashisms 0.1.5 
linter-docker 0.3.2 
linter-elm-make 0.29.0 
linter-eslint 8.5.5 
linter-js-standard 6.1.1 
linter-markdown 5.2.7 
linter-mypy 2.6.4 
linter-reek 2.4.2 
linter-rubocop 2.3.0 
linter-ruby 1.3.1 
linter-shellcheck 1.6.0 
linter-spell 0.15.0 
linter-ui-default 1.7.1 
lisp-paredit 0.6.0 
markdown-pdf 2.2.0 
markdown-preview-enhanced 0.15.10 
markdown-preview-opener 0.1.1 
markdown-scroll-sync 2.1.2 
markdown-table-editor 1.1.2 
markdown-writer 2.11.5 
maximize-panes 0.2.0 
ocaml-indent 0.7.1 
ocaml-merlin 0.14.7 
pdf-view 0.71.0 
pigments 0.40.2 
plantuml-preview 0.12.9 
platformio-ide-terminal 2.9.1 
preview-plus 1.2.7 
print-code 0.7.1 
python-indent 1.2.2 
Repl 0.5.0 
rubocop-auto-correct 1.5.1 
ruby-block 0.3.6 
ruby-solargraph 0.4.0 
script 3.18.1 
select-text 0.2.2 
select-text-between-tags 0.1.0 
sequential-number 0.5.0 
show-invisibles-plus 0.3.1 
sort-lines 0.19.0 
split-diff 1.6.0 
standard-formatter 2.8.0 
standardjs-snippets 2.6.2 
Sublime-Style-Column-Selection 1.7.5 
sync-settings 0.8.6 
todo 0.6.0 

Uncaught TypeError: this.editor.getDecreaseNextIndentPattern is not a function

[Enter steps to reproduce:]

  1. Just trying to break up lines.
annotations = _xxx_xxxx_xxxxxxxxxx_to_xxxxxx(yyyyy_yyy,
                            xxxxx_xxxx_xxxx, xxxxxxx_sql)

was trying to hit enter before yyyyy_yyy.

Atom: 1.22.0-beta0 x64
Electron: 1.6.9
OS: Mac OS X 10.12.6
Thrown From: python-indent package 1.1.1

Stack Trace

Uncaught TypeError: this.editor.getDecreaseNextIndentPattern is not a function

At /Users/dliu/.atom/packages/python-indent/lib/python-indent.js:299

TypeError: this.editor.getDecreaseNextIndentPattern is not a function
    at PythonIndent.indentHanging (/packages/python-indent/lib/python-indent.js:299:51)
    at PythonIndent.indent (/packages/python-indent/lib/python-indent.js:34:18)
    at HTMLElement.editorNewline (/packages/python-indent/lib/main.js:23:57)
    at CommandRegistry.handleCommandEvent (/Applications/Atom Beta.app/Contents/Resources/app/src/command-registry.js:381:36)
    at KeymapManager.module.exports.KeymapManager.dispatchCommandEvent (/Applications/Atom Beta.app/Contents/Resources/app/node_modules/atom-keymap/lib/keymap-manager.js:621:22)
    at KeymapManager.module.exports.KeymapManager.handleKeyboardEvent (/Applications/Atom Beta.app/Contents/Resources/app/node_modules/atom-keymap/lib/keymap-manager.js:412:28)
    at WindowEventHandler.module.exports.WindowEventHandler.handleDocumentKeyEvent (/Applications/Atom Beta.app/Contents/Resources/app/src/window-event-handler.js:100:42)
    at HTMLDocument.<anonymous> (/Applications/Atom Beta.app/Contents/Resources/app/src/window-event-handler.js:3:65)

Commands

     -0:28.4.0 core:backspace (input.hidden-input)
     -0:28 editor:move-to-end-of-line (input.hidden-input)
  2x -0:27.8.0 core:move-left (input.hidden-input)
     -0:26.8.0 editor:newline (input.hidden-input)
     -0:26.6.0 core:backspace (input.hidden-input)
     -0:26.3.0 core:save (input.hidden-input)
     -0:24.6.0 editor:consolidate-selections (input.hidden-input)
     -0:24.6.0 core:cancel (input.hidden-input)
     -0:23.2.0 core:cut (input.hidden-input)
     -0:23 core:save (input.hidden-input)
     -0:19.8.0 core:cut (input.hidden-input)
     -0:19.6.0 core:save (input.hidden-input)
     -0:07.8.0 editor:newline (input.hidden-input)
     -0:07.4.0 snippets:next-tab-stop (input.hidden-input)
     -0:07.4.0 snippets:expand (input.hidden-input)
     -0:07.4.0 editor:indent (input.hidden-input)

Non-Core Packages

atom-beautify 0.30.5 
atom-ide-ui 0.4.0 
autocomplete-python 1.10.3 
busy-signal 1.4.3 
file-icons 2.1.12 
filesize 3.0.0 
git-blame 1.3.1 
go-debug 1.5.2 
go-plus 5.5.5 
go-signature-statusbar 1.2.3 
hyperclick 0.0.0 
ide-python 0.2.1 
ide-typescript 0.6.1 
import-sf-mono 1.0.1 
indent-guide-improved 1.4.13 
intentions 1.1.5 
language-diff 0.7.0 
language-gettext 0.6.1 
language-jade 0.7.2 
language-nginx 0.8.0 
language-protobuf 0.7.1 
linter 2.2.0 
linter-eslint 8.3.2 
linter-flake8 2.2.1 
linter-jsonlint 1.3.0 
linter-sass-lint 1.8.2 
linter-ui-default 1.6.10 
MagicPython 1.0.12 
merge-conflicts 1.4.5 
pigments 0.40.2 
pristine-ui 1.1.10 
python-indent 1.1.1 
python-tools 0.6.9 
react 0.16.2 
sort-lines 0.15.0 
uglify 1.3.1 

Failed to activate after udate to atom 1.16.0-beta0

Atom: 1.16.0-beta0 x64
Electron: 1.3.13
OS: Ubuntu 16.10
Thrown From: python-indent package 1.0.0

Stack Trace

Failed to activate the python-indent package

At Cannot set property 'pythonIndent' of undefined

TypeError: Cannot set property 'pythonIndent' of undefined
  at Object.activate (/packages/python-indent/lib/main.js:25:32)
  at Package.module.exports.Package.activateNow (/app.asar/src/package.js:218:19)
  at /app.asar/src/package.js:190:32
  at Package.module.exports.Package.measure (/app.asar/src/package.js:96:15)
  at /app.asar/src/package.js:183:26
  at Package.module.exports.Package.activate (/app.asar/src/package.js:180:34)
  at PackageManager.module.exports.PackageManager.activatePackage (/app.asar/src/package-manager.js:550:34)
  at /app.asar/src/package-manager.js:531:29
  at Config.module.exports.Config.transactAsync (/app.asar/src/config.js:337:18)
  at PackageManager.module.exports.PackageManager.activatePackages (/app.asar/src/package-manager.js:526:19)
  at PackageManager.module.exports.PackageManager.activate (/app.asar/src/package-manager.js:508:46)
  at /app.asar/src/atom-environment.js:826:28

Commands

     -0:43.9.0 tree-view:show (atom-workspace.workspace.scrollbars-visible-always.compact-tab-bar.panel-shadows.panel-contrast.use-animations.compact-tree-view.theme-gazizza-syntax.theme-atom-material-ui)

Non-Core Packages

atom-material-syntax 1.0.2 
atom-material-syntax-light 0.4.6 
atom-material-ui 1.3.9 
atom-ternjs 0.18.2 
autocomplete-emojis 2.5.0 
autocomplete-paths 1.0.5 
autocomplete-python 1.8.60 
colorful-json 1.1.0 
custom-title 1.0.1 
dash 1.7.1 
date 1.2.2 
fancy-bracket-matcher 1.0.1 
file-icons 2.0.17 
focus-light 1.1.0 
foldingtext-markdown 1.3.2 
ForLatex 0.1.0 
gazizza-syntax 0.2.6 
git-control 0.8.2 
git-log 0.4.1 
git-time-machine 1.5.6 
graphviz-preview 1.7.0 
html-entities 0.4.0 
Hydrogen 1.6.0 
hydrogen-launcher 1.2.0 
indent-guide-improved 1.4.12 
isotope-light-ui 2.2.7 
itg-light-syntax 0.4.0 
kuali-light-syntax 1.1.0 
language-bnf 1.1.0 
language-cython 0.3.0 
language-diff 0.7.0 
language-dot 1.6.0 
language-latex 1.0.0 
language-lua 0.9.11 
language-matlab-octave 0.1.2 
language-pfm 0.82.0 
latex 0.42.3 
latex-autocomplete 1.0.0 
latex-completions 0.3.2 
linter 1.11.23 
linter-chktex 1.3.0 
linter-coffeescript 1.0.0 
linter-eslint 8.1.3 
linter-lua 1.0.2 
linter-pylama 0.8.13 
MagicPython 1.0.7 
markdown-pdf 1.5.0 
markdown-preview-plus 2.4.9 
markdown-themeable-pdf 1.2.0 
material 2.2.0 
material-design-syntax 1.8.0 
material-syntax 0.6.1 
minimap 4.26.8 
minimap-bookmarks 0.4.2 
minimap-cursorline 0.2.0 
minimap-find-and-replace 4.5.2 
minimap-git-diff 4.3.1 
minimap-pigments 0.2.2 
minimap-selection 4.4.0 
minimap-titles 1.10.0 
monokai-light 0.4.1 
naturerainbow-light-syntax 0.1.1 
naturezen-light-syntax 0.1.0 
new-era-light-syntax 0.3.1 
one-o-eight-syntax 0.25.3 
open-recent 5.0.0 
paper-flat-ui 1.3.6 
pdf-view 0.55.0 
pen-paper-coffee-syntax 0.14.9 
piatto-light 2.0.2 
platformio-ide-terminal 2.4.0 
python-indent 1.0.0 
release-notes 0.53.0 
show-origin 0.2.0 
snow-light-syntax 0.2.0 
sync-settings 0.8.1 
terminal-plus 0.14.5 
tree-view-git-branch 0.1.2 
underline-trailing-whitespace 1.4.2 
up2date 0.1.2 

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.