Bug 98955 - Option to not open a binary file at all / Improper detection of file modification.
Summary: Option to not open a binary file at all / Improper detection of file modifica...
Status: RESOLVED NOT A BUG
Alias: None
Product: frameworks-ktexteditor
Classification: Frameworks and Libraries
Component: general (show other bugs)
Version: unspecified
Platform: Compiled Sources Linux
: NOR wishlist
Target Milestone: ---
Assignee: KWrite Developers
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-02-09 18:47 UTC by Jason Keirstead
Modified: 2019-05-19 14:57 UTC (History)
2 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jason Keirstead 2005-02-09 18:47:31 UTC
Version:            (using KDE Devel)
Installed from:    Compiled sources

This is half bug, half wishlist - but they are so closely related I am only making one bug.

If you accidentally click on a binary file in the Kate file selector, you are presented with a warning saying "Warning, this file binary, Kate won't be able to save it properly", etc. However, there is no button in this dialog saying "Cancel", as in, do not open the file.

So, what ends up happening is, you are forced to continue opening the file, then when you go to immediatly close it (which may actually take a long time if the file Kate must display is very large and/or over a remote link), you get prompted *again* because Kate improperly detects that you midified the document (I assume because it was binary). This whole process is quite annoying.

Ideally, the first dialog should have a Cancel button to cancel opening the file at all. This is the wishlist.

Also, if you *do* open a binary file, and the text area has not been touched at all, Kate should not detect it as "modified" when you try to close it. It should just close with no warnings. This is the bug.
Comment 1 Anders Lund 2005-02-17 22:22:35 UTC
CVS commit by alund: 


Dont mark a binary file as modified, set it readonly instead.
TODO for next release: offer a back out early in the process. I can't do that now due to the string freeze.
CCBUG: 98955


  M +2 -2      kateattribute.cpp   1.9
  M +1 -1      kateautoindent.cpp   1.52
  M +1 -1      katedocument.cpp   1.793
  M +2 -1      katehighlight.cpp   1.215
  M +24 -1     katetextline.cpp   1.91
  M +16 -6     katetextline.h   1.74
  M +4 -4      kateview.cpp   1.372
  M +8 -2      kateviewinternal.cpp   1.337


--- kdelibs/kate/part/kateautoindent.cpp  #1.51:1.52
@@ -128,5 +128,5 @@ KateAutoIndent::~KateAutoIndent ()
 //END KateAutoIndent
 
-//BEGIN KateHighlightAction
+//BEGIN KateViewIndentAction
 KateViewIndentationAction::KateViewIndentationAction(KateDocument *_doc, const QString& text, QObject* parent, const char* name)
        : KActionMenu (text, parent, name), doc(_doc)

--- kdelibs/kate/part/katedocument.cpp  #1.792:1.793
@@ -2734,5 +2734,5 @@ bool KateDocument::openFile(KIO::Job * j
   {
     // this file can't be saved again without killing it
-    setModified (true);
+    setReadWrite( false );
 
     KMessageBox::information (widget()

--- kdelibs/kate/part/katehighlight.cpp  #1.214:1.215
@@ -2393,5 +2393,6 @@ void KateHighlighting::makeContextList()
                                    // of the highlighting definitions they belong to
 
-        if (identifierToUse.isEmpty() ) kdDebug(13010)<<"OHOH, unknown highlighting description referenced"<<endl;
+        if (identifierToUse.isEmpty() )
+          kdDebug(13010)<<"OHOH, unknown highlighting description referenced"<<endl;
 
         kdDebug(13010)<<"setting ("<<it.key()<<") to loaded"<<endl;

--- kdelibs/kate/part/katetextline.cpp  #1.90:1.91
@@ -222,4 +222,27 @@ int KateTextLine::cursorX(uint pos, uint
 }
 
+uint KateTextLine::position( uint visualPos, uint tw, int *remainder )
+{
+  if ( tw == 1 )
+    return visualPos;
+
+  int i = -1;
+  int res = -1;
+  while ( i < (int)visualPos )
+  {
+    i++;
+    res++;
+
+    if ( m_text[res] == '\t' )
+      i += tw - 1 - (i%tw);
+  }
+
+  if ( m_text[res] == '\t' )
+    *remainder = i - visualPos + 1; // why is the + 1 needed?
+  else
+    *remainder = 0;
+
+  return (uint)res;
+}
 
 uint KateTextLine::lengthWithTabs (uint tabChars) const

--- kdelibs/kate/part/katetextline.h  #1.73:1.74
@@ -228,4 +228,14 @@ class KateTextLine : public KShared
 
     /**
+     * Returns the position in the string of the visual position @p visualPos.
+     * If the character at the returned position is a TAB, @p remainder is set
+     * to the number of spaces needed to reach the visual position.
+     * @param visualPos the visible position given
+     * @param tabChars the tab width to use for the calculation
+     * @param remainder is a pointer to an int, which will be set to the number of spaces needed reach the exact position.
+     */
+    uint position( uint visualPos, uint tabChars, int *remainder );
+
+    /**
      * Returns the text length with tabs calced in
      * @param tabChars tabulator width in chars

--- kdelibs/kate/part/kateviewinternal.cpp  #1.336:1.337
@@ -2114,5 +2116,5 @@ void KateViewInternal::updateSelection( 
       if ( doSelect )
         m_doc->setSelection( selectAnchor, newCursor);
-      else if ( selStartCached.line() > 0 ) // we have a cached selectino, so we restore that
+      else if ( selStartCached.line() > 0 ) // we have a cached selection, so we restore that
         m_doc->setSelection( selStartCached, selEndCached );
     }
@@ -2121,5 +2123,9 @@ void KateViewInternal::updateSelection( 
   }
   else if ( !(m_doc->configFlags() & KateDocument::cfPersistent) )
+  {
     m_doc->clearSelection();
+    selStartCached.setLine( -1 );
+    selectAnchor.setLine( -1 );
+  }
 }
 
@@ -2769,5 +2775,5 @@ void KateViewInternal::mouseReleaseEvent
     case LeftButton:
       m_selectionMode = Default;
-      selStartCached.setLine( -1 );
+//       selStartCached.setLine( -1 );
 
       if (m_selChangedByUser)


Comment 2 Christoph Cullmann 2005-09-29 15:34:13 UTC
fine, the backout is really a wish, I like to view my binary files, and all the warnings and read-only stuff should really make it save even atm.
Comment 3 esigra 2008-03-27 21:48:23 UTC
When will the string freeze be over so that this can be fixed?
Comment 4 Anders Lund 2008-03-28 15:39:37 UTC
Now is a good time :)
Comment 5 Konstantin 2009-08-27 21:03:32 UTC
Can I add a bit?
It would be great to show a warning/confirmation dialog for very large files (no matter text or binary) also.
Comment 6 Christoph Cullmann 2019-05-19 14:57:54 UTC
Dear user, this wish list item is now closed, as it wasn't touched in the last year and no contributor stepped up to implement it.

The Kate/KTextEditor team is small and we can just try to keep up with fixing bugs.

Therefore wishes that show no activity for a years or more will be closed from now on to keep at least a bit overview about 'current' wishs of the users.
If you want your feature to be implemented, please step up to provide some patch for it.

If you think it is really needed, you can reopen your request, but keep in mind,
if no new good arguments are made and no people get attracted to help out to implement it,
it will expire in a year again.

We have a nice website https://kate-editor.org that provides all the information needed to contribute, please make use of it.

Patches can be handed in via https://phabricator.kde.org/differential/

Greetings
Christoph Cullmann