Keep / adapt indentation level of copied / pasted / drag&dropped script snippets

Issue #171 resolved
M. Gronle created an issue

Currently, there are still many cases where the indentation level of copied, cut, pasted or drag&dropped code snippets is not correctly preserved. Of course it is not possible to find a set of rules that work in all situations. However, it is desired to improve the current situation.

The improvements must probably tackle both the cut/copy or drag part as well as the paste or drop part. Then, it is also possible to provide a better behaviour if parts of a script is copied to an external editor or if copied text from an external editor is pasted in itom.

Proposal for Cut/Copy/Drag (to clipboard):

  1. For a single line snippet, do not change the text
  2. For a multiline snippet, change the first line as follows: If there are whitespace characters (space, tab) before the start cursor position, prepend all whitespace characters before the start cursor to the first line of the cut/copied/dragged snippet.

Proposal for Paste/Drop (from clipboard):

  1. For a single line snippet, simply insert it
  2. For a multiline snippet, do the following things:
    a) get the prepended whitespace substring of the line, where this substring has the shortest length
    b) From each line, remove this shortest whitespace substring from the start of each line
    c) Create a new substring, that consists of spaces or tabs (depending on the current indenation settings) and whose length corresponds to the column of the current cursor position.
    d) Prepend this new substring to every line of the snippet to be inserted, besides the first line.
    e) Paste or insert the snippet.

Comments (2)

  1. Log in to comment